Please note: Traefik version 2 has pushed new minor versions since this article was published, and doesn’t have a “v2” tag to simplify use.
Please check Traefik’s images on Docker Hub for the latest minor version of version 2.
Trying to learn the basics of Traefik to get a working configuration deployed can be a bit of a bear, and a constant pain point for many. Time permitting, I try to answer people’s questions when I can, so I figured that this article might help reduce the barrier to entry for people trying to grasp the fundamental concepts of Traefik 2.5.
If you haven’t heard of Traefik, please allow me to quote directly from the source:
Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components (Docker, Swarm mode, Kubernetes, Marathon, Consul, Etcd, Rancher, Amazon ECS, …) and configures itself automatically and dynamically.Traefik GitHub repository
It can be a bit confusing, but Traefik has two configuration types:
- Startup (referred to as the static configuration).
- Routing (referred to as the dynamic configuration), where changes are hot-reloaded (e.g. swapping or scaling backend servers without interrupting service to your audience).
Initially, Traefik started with the TOML format but, thankfully, added support for the YAML format with version 2.0’s release in September 2019. In this article, I’ve provided both TOML and YAML implementations for comparison. Use what works best for you.
I considered writing this article only with YAML, but so many of the examples on the Internet are in the TOML format, and the Docker labels options for Traefik have a similar (if not identical) syntax. Since this article is geared towards helping people get over the learning curve as quickly as possible, I opted for the path of least resistance.
Traefik supports the ability to generate/renew certificates from the Let’s Encrypt! Certificate Authority, but I use an administrative server to do this and then distribute them to my servers.
One reply on “Traefik 2.5 quick-start guide”
Great article. Will definitely try out the local plugins