Created
December 2, 2020 22:49
-
-
Save corusm/c5d2e2fb54fef3cb4cd31c05cdea8817 to your computer and use it in GitHub Desktop.
Traefik Docker Compose Beginner Guide
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.7' | |
networks: | |
main: | |
external: true | |
services: | |
proxy: | |
image: "traefik:v2.2" | |
container_name: reverse-proxy | |
restart: always | |
command: | |
- --api=true | |
- --api.insecure=true | |
- --ping | |
- --providers.docker=true | |
- --providers.docker.network=main | |
- --providers.docker.exposedbydefault=false | |
- --entrypoints.web.address=:80 | |
- --entrypoints.web-secure.address=:443 | |
- --certificatesresolvers.myhttpchallenge.acme.httpchallenge=true | |
- --certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web | |
- --certificatesresolvers.myhttpchallenge.acme.caserver=https://acme-v02.api.letsencrypt.org/directory | |
- --certificatesresolvers.myhttpchallenge.acme.email=postmaster@test.com | |
- --certificatesresolvers.myhttpchallenge.acme.storage=/letsencrypt/acme.json | |
ports: | |
- "80:80" | |
- "443:443" | |
networks: | |
- "main" | |
volumes: | |
- ./letsencrypt:/letsencrypt | |
- /var/run/docker.sock:/var/run/docker.sock:ro | |
- ./config.toml:/etc/traefik/traefik.config.toml:ro | |
- ./certs:/etc/certs:ro | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.proxy-https.rule=Host(`proxy.corusm.de`)" | |
- "traefik.http.routers.proxy-https.entrypoints=web-secure" | |
- "traefik.http.routers.proxy-https.tls=true" | |
- "traefik.http.routers.proxy-https.service=api@internal" | |
- "traefik.http.routers.proxy-https.middlewares=traefik-auth" | |
- "traefik.http.middlewares.traefik-auth.basicauth.users=test:$$apr1$$.LOx3R4y$$/OjfdK3pSGiT/flYY42uS1" | |
# echo $(htpasswd -nb username password) | sed -e s/\\$/\\$\\$/g | |
- "traefik.http.routers.proxy-http.rule=Host(`proxy.corusm.de`)" | |
- "traefik.http.routers.proxy-http.entrypoints=web" | |
- "traefik.http.routers.proxy-http.middlewares=https_redirect" | |
- "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https" | |
- "traefik.http.middlewares.https_redirect.redirectscheme.permanent=true" | |
whoami: | |
image: "containous/whoami" | |
container_name: Traefik-whoami-main | |
restart: always | |
networks: | |
- "main" | |
labels: | |
- traefik.enable=true | |
- traefik.http.routers.whoami.rule=Host(`whoami.example.com`) | |
- traefik.http.routers.whoami.entrypoints=web | |
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https | |
- traefik.http.routers.whoami.middlewares=redirect-to-https@docker | |
- traefik.http.routers.whoami-secured.rule=Host(`whoami.example.com`) | |
- traefik.http.routers.whoami-secured.tls=true | |
- traefik.http.routers.whoami-secured.tls.certresolver=myhttpchallenge | |
- traefik.http.routers.whoami-secured.entrypoints=web-secure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment