My boring Blog

Mauro Frigerio blog

Traefik 2.x examples

09-06-2020 2 min read Article

TLTR

On GitHub you can find a repository with some examples of traefik (version 2.x) configuration. You find the docker-compose and the guide on how to use this.

Feel free to report the issue if something is not working.

Intro

I have no trouble saying that I am a bad developer (no problem is not my work). In my home network, I play with some systems. For 2-3 years I experiment with docker and my container number it’s growing every month. Sometimes it is only a test and the container lives for a few hours. But there is a group of services that are important for my home, like:

  • wifi and network controller
  • automation manager
  • time database for house sensors
  • sensor data visualization
  • container update manager

Really important for me is the use of SSL certificates and so I can avoid this boring message on the browser that the site is not sure. Or the self-signed certificate is not valid. I need Let’s Encrypt to generate the certificates, but I don’t want to configure every container with a single certificate and renew it every 90 days.

With some research on the Internet, I have found traefik and some other reverse-proxy. My choice was sure for traefik, but before I managed this its took me some time.

Prerequisites

  • a domain that you own
  • optional: CloudFlare account (for DNS challenge)
  • docker and docker-compose installation

Example structure

On my GitHub repository, you can find some examples of traefik configuration. I suggest you follow this order if you try traefik for the first time.

  1. Basic: basic configuration and SSL certificates
  2. File provider: connect services outside docker
  3. Dashboard: secure the traefik dashboard
  4. OAuth: secure access to defined websites

How to use

  1. In the root directory of the repo, you find the var.env file. It contain all your’s variables that are used in these examples. Change the name in .env and place it in the same directory as the docker-compose.yml.

  2. There is a separate folder for every example you find a docker-compose.yml file with all needed configuration to run the case. In the same directory, you find a README.md with steps to follow.

  3. Enjoy it!

Help

If you find some error or improving possibilities please create a new issue on GitHub. Wen can improve these examples.