diff --git a/docker-compose.yml b/docker-compose.yml index c045349..20d0cb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/env.example b/env.example index 4568d29..b618a58 100644 --- a/env.example +++ b/env.example @@ -1,5 +1,7 @@ TRAEFIK_VERSION=2.4 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