Traefik is a reverse proxy and load balancer designed for dynamic container environments. Automatic configuration, Let’s Encrypt integration and native Docker support.
Nginx and HAProxy in the container era¶
Nginx and HAProxy are excellent reverse proxies, but they require static configuration. In a dynamic container environment where services are constantly being created and destroyed, manually updating the configuration is unsustainable.
Traefik is designed for this dynamic world — it automatically detects new services and configures routing without a restart.
Automatic configuration from Docker¶
Traefik reads Docker labels and automatically configures routing:
# docker-compose.yml
version: '2'
services:
traefik:
image: traefik
command: --docker
ports:
- "80:80"
- "8080:8080" # Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock
web:
image: my-web-app
labels:
- "traefik.frontend.rule=Host:app.example.com"
- "traefik.port=3000"
Start a container with labels — Traefik automatically creates a routing rule. Remove the container — the rule disappears. Zero config.
Let’s Encrypt and automatic HTTPS¶
Traefik integrates Let’s Encrypt — automatic HTTPS for all services:
# traefik.toml
[acme]
email = "[email protected]"
storage = "acme.json"
entryPoint = "https"
[acme.httpChallenge]
entryPoint = "http"
Traefik automatically:
- Obtains a certificate for each new domain
- Renews certificates before they expire
- Terminates TLS
- Redirects HTTP to HTTPS
No manual certificate management.
Dashboard and monitoring¶
Traefik offers a built-in web dashboard with an overview of:
- Active frontends and backends
- Service health status
- Request metrics
- Real-time configuration
Integration with Prometheus for metrics and support for middlewares (rate limiting, basic auth, circuit breaker) round out the functionality.
Conclusion: the reverse proxy for the modern stack¶
Traefik is the ideal reverse proxy for Docker and Kubernetes environments. Automatic configuration and Let’s Encrypt integration eliminate operational overhead. For static environments nginx remains king, but for dynamic microservices Traefik is the clear choice.
Need help with implementation?
Our experts can help with design, implementation, and operations. From architecture to production.
Contact us