mirror of
https://github.com/bluepuma77/traefik-best-practice.git
synced 2025-12-21 11:45:00 +01:00
docker-swarm-traefik-dnschallenge
Simple docker-compose.yml template to run Traefik and a whoami service with Docker Swarm and LetsEncrypt dnsChallenge.
Features:
- Traefik will be deployed to all manager nodes (to have access to Swarm docker.sock)
- Traefik is listening on ports 80 (http) and 443 (https) on the node itself
- All http requests will be redirected to secure https requests
- Docker services with label
traefik.enable=truewill automatically be discovered by Traefik - Letsencrypt
dnsChallengewill automatically generate TLS/SSL certificates for all domains inHost() - Optionally generate wildcard TLS certs. But
main/sanscan savely be removed - Traefik log (
level=INFO) and access log are enabled to container stdout/stderr - Traefik dashboard is enabled at
https://traefik.example.com/dashboard/with user/pass test/test - Traefik
whoamiwill be deployed to all Swarm nodes, available athttps://whoami.example.com
Deployment:
- Adapt all domain names in
Host() - Adapt
acme.emailanddnschallenge.provider, also adapt required env variables - Adapt dashboard username/password
- For production: write logs files to mounted folder on host
- Run
docker stack deploy -c docker-compose.yml myProxy
Challenges:
- Traefik CE (community edition) is not LetsEncrypt cluster-enabled. If you have multiple Traefik instances, each will generate an indiviual TLS cert.
- Make sure to persist the LetsEncrypt TLS certs, as LetsEncrypt has strict limits. Note that the content of volumes is not shared across nodes.