Compare commits

...

2 Commits

Author SHA1 Message Date
Bryan Joshua Pedini
44354e0ed1 variabilized access log, router name, match rule 2022-01-01 22:27:36 +01:00
Bryan Joshua Pedini
6c374a2460 generalize domain name in env.example 2022-01-01 21:26:40 +01:00
2 changed files with 18 additions and 13 deletions

View File

@ -4,7 +4,7 @@ services:
traefik:
command:
# when debugging is needed
- --accesslog=false
- --accesslog=${TRAEFIK_ACCESSLOG}
# enable Træfik dashboard
- --api.dashboard=true
# configure Let's Encrypt automatic certificates
@ -41,23 +41,23 @@ services:
- traefik.http.middlewares.http-to-https.redirectscheme.scheme=https
- traefik.http.middlewares.http-to-https.redirectscheme.permanent=true
### Section HTTP
- traefik.http.routers.http-traefik_bjphoster_com.entrypoints=http
- traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.entrypoints=http
# only some people can access the dashboard, hence protect it with it's whitelist
- traefik.http.routers.http-traefik_bjphoster_com.middlewares=dashboard-whitelist
- traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.middlewares=dashboard-whitelist
# redirect Træfik dashboard to HTTPS only
- traefik.http.routers.http-traefik_bjphoster_com.middlewares=http-to-https
- traefik.http.routers.http-traefik_bjphoster_com.rule=Host(`traefik.bjphoster.com`)
- traefik.http.routers.http-traefik_bjphoster_com.service=api@internal
- traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.middlewares=http-to-https
- traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.rule=Host(`${TRAEFIK_MATCHRULE}`)
- traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.service=api@internal
### Section HTTPS
- traefik.http.routers.https-traefik_bjphoster_com.entrypoints=https
- traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.entrypoints=https
# only some people can access the dashboard, hence protect it with it's whitelist
- traefik.http.routers.https-traefik_bjphoster_com.middlewares=dashboard-whitelist
- traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.middlewares=dashboard-whitelist
# configure Træfik dashboard to be the exposed service
- traefik.http.routers.https-traefik_bjphoster_com.rule=Host(`traefik.bjphoster.com`)
- traefik.http.routers.https-traefik_bjphoster_com.service=api@internal
- traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.rule=Host(`${TRAEFIK_MATCHRULE}`)
- traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.service=api@internal
# of course, enable TLS and it's certificate provider
- traefik.http.routers.https-traefik_bjphoster_com.tls=true
- traefik.http.routers.https-traefik_bjphoster_com.tls.certresolver=letsencrypt
- traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.tls=true
- traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.tls.certresolver=letsencrypt
networks:
- traefik-proxy
ports:

View File

@ -1,5 +1,7 @@
TRAEFIK_VERSION=2.4
TRAEFIK_CONTAINER_NAME=traefik.bjphoster.com
TRAEFIK_CONTAINER_NAME=traefik.mydomain.com
TRAEFIK_MATCHRULE=traefik.mydomain.com
TRAEFIK_ROUTER_NAME=traefik_mydomain_com
TRAEFIK_LOGLEVEL=INFO
TRAEFIK_PILOT_TOKEN=
TRAEFIK_DASHBOARD_WHITELIST=1.2.3.4/24
@ -7,3 +9,6 @@ TRAEFIK_DASHBOARD_WHITELIST=1.2.3.4/24
# Certificate provider
HETZNER_API_KEY=
LETSENCRYPT_EMAIL=admin@mydomain.com
# Debugging
TRAEFIK_ACCESSLOG=false