Traefik cheatsheet
CLI and service
| Command | Description |
|---|---|
traefik version | Binary version |
traefik --configFile=/etc/traefik/traefik.yml | Start with static config |
systemctl status traefik | Service status (if systemd-managed) |
docker logs traefik -f | Follow Traefik container logs |
ss -tlnp | grep traefik | Check listeners |
Dashboard and API
| URL / command | Description |
|---|---|
http://localhost:8080/dashboard/ | Web dashboard (if enabled) |
curl -s http://localhost:8080/api/http/routers | List HTTP routers (JSON) |
curl -s http://localhost:8080/api/http/services | List HTTP services |
curl -s http://localhost:8080/api/rawdata | Full dynamic config snapshot |
Docker labels (minimal router)
labels:
- "traefik.enable=true"
- "traefik.http.routers.myapp.rule=Host(`api.example.com`)"
- "traefik.http.routers.myapp.entrypoints=websecure"
- "traefik.http.routers.myapp.tls.certresolver=letsencrypt"
- "traefik.http.services.myapp.loadbalancer.server.port=8080"
Static config snippet (ACME)
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
certificatesResolvers:
letsencrypt:
acme:
email: ops@example.com
storage: /letsencrypt/acme.json
httpChallenge:
entryPoint: web
Kubernetes
| Command | Description |
|---|---|
kubectl get ingressroute -A | Traefik IngressRoute CRDs |
kubectl get middleware -A | Traefik middleware resources |
kubectl describe ingressroute myroute -n myns | Route details and events |
kubectl logs -n traefik deploy/traefik | Traefik controller logs |
Testing routes
| Command | Description |
|---|---|
curl -vI -H "Host: api.example.com" http://127.0.0.1/ | Test router match via Host header |
curl -vI https://api.example.com | Test TLS end-to-end |
dig +short api.example.com | Confirm DNS for ACME |
Pro tips
- Check the dashboard or
/api/http/routerswhen a route "does nothing" — the router may not exist traefik.enable=trueis required on Docker containers; without it Traefik ignores them- ACME storage (
acme.json) must be writable and backed up — it holds account keys - Middleware order matters — auth before strip-prefix, etc.
Practice scenarios
Hands-on Traefik scenarios on live Linux VMs: traefik