variabilized access log, router name, match rule

This commit is contained in:
Bryan Joshua Pedini 2022-01-01 22:27:36 +01:00
parent f63b75e636
commit ccf95deedc
2 changed files with 17 additions and 12 deletions

View File

@ -4,7 +4,7 @@ services:
traefik: traefik:
command: command:
# when debugging is needed # when debugging is needed
- --accesslog=false - --accesslog=${TRAEFIK_ACCESSLOG}
# enable Træfik dashboard # enable Træfik dashboard
- --api.dashboard=true - --api.dashboard=true
# configure Let's Encrypt automatic certificates # 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.scheme=https
- traefik.http.middlewares.http-to-https.redirectscheme.permanent=true - traefik.http.middlewares.http-to-https.redirectscheme.permanent=true
### Section HTTP ### 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 # 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 # redirect Træfik dashboard to HTTPS only
- traefik.http.routers.http-traefik_bjphoster_com.middlewares=http-to-https - traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.middlewares=http-to-https
- traefik.http.routers.http-traefik_bjphoster_com.rule=Host(`traefik.bjphoster.com`) - traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.rule=Host(`${TRAEFIK_MATCHRULE}`)
- traefik.http.routers.http-traefik_bjphoster_com.service=api@internal - traefik.http.routers.http-${TRAEFIK_ROUTER_NAME}.service=api@internal
### Section HTTPS ### 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 # 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 # 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_ROUTER_NAME}.rule=Host(`${TRAEFIK_MATCHRULE}`)
- traefik.http.routers.https-traefik_bjphoster_com.service=api@internal - traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.service=api@internal
# of course, enable TLS and it's certificate provider # of course, enable TLS and it's certificate provider
- traefik.http.routers.https-traefik_bjphoster_com.tls=true - traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.tls=true
- traefik.http.routers.https-traefik_bjphoster_com.tls.certresolver=letsencrypt - traefik.http.routers.https-${TRAEFIK_ROUTER_NAME}.tls.certresolver=letsencrypt
networks: networks:
- traefik-proxy - traefik-proxy
ports: ports:

View File

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