Last active
September 1, 2024 15:10
-
-
Save acouvreur/0514aedb813e2bf9b32e456c177df0e7 to your computer and use it in GitHub Desktop.
Traefik with HTTPS (with redirect and wildcard certificate) and Host rule autoconfiguration (for docker swarm)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
services: | |
traefik: | |
image: traefik:latest | |
ports: | |
- 80:80 | |
- 443:443 | |
command: | |
- --api=true | |
- --entrypoints.http.address=:80 | |
- --entrypoints.http.http.redirections.entryPoint.to=https | |
- --entrypoints.http.http.redirections.entryPoint.scheme=https | |
- --entrypoints.https.address=:443 | |
- --entrypoints.https.http.tls.certresolver=ovh | |
- --entrypoints.https.http.tls.domains[0].main=domain.me | |
- --entrypoints.https.http.tls.domains[0].sans=*.domain.me | |
- --certificatesresolvers.ovh.acme.dnsChallenge.provider=ovh | |
- [email protected] | |
- --certificatesresolvers.ovh.acme.storage=/etc/traefik/acme/acme.json | |
- --providers.docker=true | |
- --providers.docker.swarmmode=true | |
- --providers.docker.exposedByDefault=false | |
- --providers.docker.defaultRule=Host(`{{ trimPrefix (print (normalize (index .Labels "com.docker.stack.namespace")) "-") .Name }}.domain.me`) | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock:ro | |
deploy: | |
labels: | |
# Automatically available at traefik.domain.me | |
- traefik.enable=true | |
- traefik.http.routers.traefik.service=api@internal | |
- traefik.http.services.traefik.loadbalancer.server.port=8080 | |
whoami: | |
image: containous/whoami:latest | |
deploy: | |
labels: | |
# Automatically available at whoami.domain.me | |
- traefik.enable=true | |
- traefik.http.services.whoami.loadbalancer.server.port=80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment