101 | Traefik: A Dynamic Router for the Container Era
Published on 2025-09-05
Introduction
Unlike Caddy, which focuses on simplicity, Traefik (pronounced Traffic) was built to solve one specific task: routing traffic in dynamic environments.
It is a reverse proxy and load balancer designed specifically for Docker, Kubernetes, and other orchestrators. The main difference from Nginx is not static configuration, but the ability to automatically discover and serve services.
Key Concepts: Dynamic Configuration
The philosophy of Traefik is built on the principle of Service Discovery.
Instead of static configurations, Traefik can “listen” to the Docker or Kubernetes API and automatically create routes for containers as soon as they start.
This eliminates the need to manually edit the configuration every time a new service is deployed.
Installation comes down to running a single Traefik container, making it easy to integrate into any containerized infrastructure.
Dynamic Proxying for Developers
Traefik takes the headache out of routing. You just need to add labels to your container — and routes will be created automatically.
Example Configuration with Docker Compose
Let’s say you have a frontend and a backend, and you want Traefik to route traffic to them.
version: '3'
services:
frontend:
image: my-frontend-app
labels:
- "traefik.http.routers.frontend.rule=Host(`my-app.dev`)"
- "traefik.http.routers.frontend.entrypoints=websecure"
- "traefik.http.services.frontend.loadbalancer.server.port=3000"
backend:
image: my-backend-api
labels:
- "traefik.http.routers.backend.rule=Host(`api.my-app.dev`)"
- "traefik.http.routers.backend.entrypoints=websecure"
- "traefik.http.services.backend.loadbalancer.server.port=8000"
After running docker-compose up, Traefik will:
- automatically create routes for my-app.dev and api.my-app.dev,
- obtain and configure SSL certificates,
- start load balancing traffic.
And all of this happens without editing the Traefik configuration!
Convenience for CI/CD
Traefik integrates seamlessly into CI/CD pipelines, especially in microservice architectures.
- Automation: the pipeline just deploys containers, and Traefik sets up the routes automatically.
- Easy deployment: no need to manually edit configs — just restart the container.
- Kubernetes integration: support for CRDs and ingress controllers makes Traefik one of the best solutions for k8s.
Conclusion
Traefik is a dynamic router built for the container era. It removes the routine of manual configuration, manages SSL automatically, and enables CI/CD pipelines to be truly seamless.
If you work with Docker or Kubernetes and are tired of static configurations — Traefik will become your reliable tool.