Created
January 20, 2021 10:22
-
-
Save lmyyao/846f0470d66f340ae33b83cf6394642b to your computer and use it in GitHub Desktop.
traefik tls docker example
This file contains 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' | |
services: | |
traefik: | |
# The official v2 Traefik docker image | |
image: traefik:v2.3.5 | |
# Enables the web UI and tells Traefik to listen to docker | |
command: | |
- --api.insecure=true | |
- --providers.docker | |
#- --providers.docker.swarmMode=true | |
- --entrypoints.http.address=:8400 | |
#- --providers.docker.watch=true | |
- --entrypoints.websecure.address=:443 | |
- --providers.file.filename=/certs/conf.yml | |
- --providers.file.watch=true | |
#- --providers.docker.tls.caOptional=false | |
#- --providers.docker.tls.cert=/certs/dashboard.crt | |
#- --providers.docker.tls.key=/certs/dashboard.key | |
ports: | |
# The HTTP port | |
- "8400:8400" | |
- "443:443" | |
# The Web UI (enabled by --api.insecure=true) | |
- "8080:8080" | |
volumes: | |
# So that Traefik can listen to the Docker events | |
- /var/run/docker.sock:/var/run/docker.sock | |
- /root/traefik/certs:/certs | |
# ... | |
whoami: | |
# A container that exposes an API to show its IP address | |
image: traefik/whoami | |
volumes: | |
- /root/traefik/certs:/certs | |
ports: | |
- "7777:80" | |
#command: | |
#- --cert | |
#- /certs/dashboard.crt | |
#- --key | |
#- /certs/dashboard.key | |
labels: | |
- "traefik.http.routers.whoami.entrypoints=websecure" | |
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)" | |
- "traefik.http.routers.whoami.middlewares=redirect-to-https" | |
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" | |
- "traefik.http.routers.whoami.tls=true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment