Nginx needs manual config updates for every service. Traefik discovers your Docker containers and Kubernetes services automatically.
What Is Traefik?
Traefik is a modern reverse proxy and load balancer that auto-discovers services from Docker, Kubernetes, Consul, and more. Add a label to your container — Traefik routes traffic to it.
Docker Auto-Discovery
# docker-compose.yml
services:
traefik:
image: traefik:v3.0
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.le.acme.email=you@example.com"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
my-app:
image: my-app:latest
labels:
- "traefik.enable=true"
- "traefik.http.routers.myapp.rule=Host(\`myapp.example.com\`)"
- "traefik.http.routers.myapp.tls.certresolver=le"
Start the container → Traefik detects it → routes myapp.example.com → auto-HTTPS. No config reload.
Kubernetes Auto-Discovery
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: websecure
spec:
rules:
- host: myapp.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
Middleware
labels:
# Rate limiting
- "traefik.http.middlewares.ratelimit.ratelimit.average=100"
# Basic auth
- "traefik.http.middlewares.auth.basicauth.users=admin:$$apr1$$..."
# Redirect HTTP to HTTPS
- "traefik.http.middlewares.redirect.redirectscheme.scheme=https"
# Strip prefix
- "traefik.http.middlewares.strip.stripprefix.prefixes=/api"
Why Traefik
- Auto-discovery — Docker, K8s, Consul, ECS — no manual config
- Automatic HTTPS — Let's Encrypt built-in
- Dynamic config — no reloads, no restarts
- Dashboard — real-time traffic visualization
- Middleware — rate limiting, auth, circuit breaking, retry
- TCP/UDP — not just HTTP
Building cloud-native infrastructure? Check out my developer tools or email spinov001@gmail.com.
Top comments (0)