-
-
Save futurist/5864f152ef21d849257b6b234b465963 to your computer and use it in GitHub Desktop.
Pristine config for Traefik 2.0, Docker, and LetsEncrypt with sample container. Includes a HTTP to HTTPS redirect
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' | |
services: | |
traefik: | |
container_name: traefik | |
image: traefik:v2.0 | |
command: | |
- "--api.insecure=true" | |
- "--providers.docker=true" | |
- "--entryPoints.web.address=:80" | |
- "--entryPoints.websecure.address=:443" | |
- "--certificatesResolvers.le.acme.email=<YOUR_EMAIL>" | |
- "--certificatesResolvers.le.acme.storage=acme.json" | |
- "--certificatesResolvers.le.acme.tlsChallenge=true" | |
- "--certificatesResolvers.le.acme.httpChallenge=true" | |
- "--certificatesResolvers.le.acme.httpChallenge.entryPoint=web" | |
restart: always | |
ports: | |
- 80:80 | |
- 443:443 | |
- 8080:8080 | |
networks: | |
- web | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
- ./acme.json:/acme.json | |
labels: | |
# Redirect all HTTP to HTTPS permanently | |
- traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`) | |
- traefik.http.routers.http_catchall.entrypoints=web | |
- traefik.http.routers.http_catchall.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: "simple-service" | |
restart: always | |
networks: | |
- web | |
labels: | |
- traefik.http.routers.whoami.rule=Host(`<YOUR_DOMAIN_NAME>`) | |
- traefik.http.routers.whoami.tls=true | |
- traefik.http.routers.whoami.tls.certresolver=le | |
networks: | |
web: | |
external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment