2022-01-22 22:22:01 +00:00
|
|
|
---
|
2021-08-13 16:15:42 +00:00
|
|
|
services:
|
|
|
|
traefik:
|
2022-01-15 21:35:10 +00:00
|
|
|
image: traefik:${TRAEFIK_VERSION}
|
|
|
|
container_name: ${TRAEFIK_CONTAINER_NAME}
|
|
|
|
restart: unless-stopped
|
2021-08-13 16:15:42 +00:00
|
|
|
command:
|
|
|
|
# when debugging is needed
|
2022-01-01 21:27:36 +00:00
|
|
|
- --accesslog=${TRAEFIK_ACCESSLOG}
|
2021-08-13 16:15:42 +00:00
|
|
|
# enable Træfik dashboard
|
|
|
|
- --api.dashboard=true
|
|
|
|
# configure Let's Encrypt automatic certificates
|
2022-01-22 22:27:55 +00:00
|
|
|
- --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.dnschallenge=true
|
2022-08-02 10:03:51 +00:00
|
|
|
- --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.dnschallenge.provider=${TRAEFIK_DNSPROVIDER}
|
2022-01-22 22:27:55 +00:00
|
|
|
- --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.email=${LETSENCRYPT_EMAIL}
|
|
|
|
- --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.keytype=RSA4096
|
|
|
|
- --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.storage=/certs.json
|
2021-08-13 16:15:42 +00:00
|
|
|
# we listen on both HTTP and HTTPS
|
|
|
|
- --entrypoints.http.address=:80
|
|
|
|
- --entrypoints.https.address=:443
|
|
|
|
# logging level
|
|
|
|
- --log.level=${TRAEFIK_LOGLEVEL}
|
|
|
|
# Træfik Pilot token (of course retrieved from dotenv)
|
|
|
|
- --pilot.token=${TRAEFIK_PILOT_TOKEN}
|
|
|
|
# we only use Docker (for now)
|
|
|
|
- --providers.docker=true
|
|
|
|
# and we want to manually specify exposed containers
|
|
|
|
- --providers.docker.exposedbydefault=false
|
|
|
|
- --providers.docker.watch=true
|
2022-01-15 21:39:35 +00:00
|
|
|
# should not need, but just in case, a folder for dynamic config files is also configured
|
|
|
|
- --providers.file.directory=/config
|
2021-08-13 16:15:42 +00:00
|
|
|
- --providers.file.watch=true
|
2022-08-02 10:03:51 +00:00
|
|
|
env_file:
|
|
|
|
- ${TRAEFIK_DNSPROVIDER_ENVFILE}
|
2021-08-13 16:15:42 +00:00
|
|
|
labels:
|
|
|
|
# expose Træfik using Træfik (dashboard)
|
2022-01-22 22:27:55 +00:00
|
|
|
- traefik.enable=${TRAEFIK_ENABLED}
|
2021-08-13 16:15:42 +00:00
|
|
|
# configure a global whitelist for my home
|
|
|
|
- traefik.http.middlewares.dashboard-whitelist.ipwhitelist.sourcerange=${TRAEFIK_DASHBOARD_WHITELIST}
|
|
|
|
# configure the global redirect middleware
|
|
|
|
- traefik.http.middlewares.http-to-https.redirectscheme.scheme=https
|
|
|
|
- traefik.http.middlewares.http-to-https.redirectscheme.permanent=true
|
|
|
|
### Section HTTP
|
2022-01-15 21:39:35 +00:00
|
|
|
- traefik.http.routers.http-${TRAEFIK_ROUTER}.entrypoints=http
|
2021-08-13 16:15:42 +00:00
|
|
|
# only some people can access the dashboard, hence protect it with it's whitelist
|
2022-01-15 21:39:35 +00:00
|
|
|
- traefik.http.routers.http-${TRAEFIK_ROUTER}.middlewares=dashboard-whitelist
|
2021-08-13 16:15:42 +00:00
|
|
|
# redirect Træfik dashboard to HTTPS only
|
2022-01-15 21:39:35 +00:00
|
|
|
- traefik.http.routers.http-${TRAEFIK_ROUTER}.middlewares=http-to-https
|
|
|
|
- traefik.http.routers.http-${TRAEFIK_ROUTER}.rule=Host(`${TRAEFIK_MATCHRULE}`)
|
|
|
|
- traefik.http.routers.http-${TRAEFIK_ROUTER}.service=api@internal
|
2021-08-13 16:15:42 +00:00
|
|
|
### Section HTTPS
|
2022-01-15 21:39:35 +00:00
|
|
|
- traefik.http.routers.https-${TRAEFIK_ROUTER}.entrypoints=https
|
2021-08-13 16:15:42 +00:00
|
|
|
# only some people can access the dashboard, hence protect it with it's whitelist
|
2022-01-15 21:39:35 +00:00
|
|
|
- traefik.http.routers.https-${TRAEFIK_ROUTER}.middlewares=dashboard-whitelist
|
2021-08-13 16:15:42 +00:00
|
|
|
# configure Træfik dashboard to be the exposed service
|
2022-01-15 21:39:35 +00:00
|
|
|
- traefik.http.routers.https-${TRAEFIK_ROUTER}.rule=Host(`${TRAEFIK_MATCHRULE}`)
|
|
|
|
- traefik.http.routers.https-${TRAEFIK_ROUTER}.service=api@internal
|
2021-08-13 16:15:42 +00:00
|
|
|
# of course, enable TLS and it's certificate provider
|
2022-01-22 22:27:55 +00:00
|
|
|
- traefik.http.routers.https-${TRAEFIK_ROUTER}.tls=${TRAEFIK_TLSENABLED}
|
|
|
|
- traefik.http.routers.https-${TRAEFIK_ROUTER}.tls.certresolver=${TRAEFIK_CERTRESOLVER}
|
2021-08-13 16:15:42 +00:00
|
|
|
networks:
|
2022-01-15 22:09:46 +00:00
|
|
|
- traefik
|
2021-08-13 16:15:42 +00:00
|
|
|
ports:
|
|
|
|
- 80:80
|
|
|
|
- 443:443
|
|
|
|
volumes:
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
2022-01-15 21:39:35 +00:00
|
|
|
- ./config:/config:ro
|
2022-01-22 22:21:37 +00:00
|
|
|
- ./certs.json:/certs.json
|
2021-08-13 16:15:42 +00:00
|
|
|
|
|
|
|
networks:
|
2022-01-15 22:09:46 +00:00
|
|
|
traefik:
|
2021-08-13 16:15:42 +00:00
|
|
|
external: true
|
2022-01-15 22:09:46 +00:00
|
|
|
name: ${TRAEFIK_NETWORK}
|