16 Commits
1.0.1 ... 1.2.0

Author SHA1 Message Date
09f3ec9f70 less static configuration, more variables 2024-05-02 13:34:32 +02:00
92f3d7bc79 removed container name - from env example too 2023-12-06 00:06:26 +01:00
9995f30c3b removed container name 2023-04-05 13:13:57 +02:00
026a2a272b Træfik Pilot is deprecated, removed 2023-04-05 12:09:05 +02:00
deb1b7ccb5 moved hsts middleware from section HTTP to section HTTPS 2022-08-16 16:06:40 +02:00
503f438bdf enhanced security through HSTS headers' middleware 2022-08-16 15:53:27 +02:00
a1428f0d3b clarified middlewares' comments 2022-08-16 15:45:53 +02:00
a40e9ad9ad added DNS resolvers for SSL DNS challenge 2022-08-02 12:53:36 +02:00
e2b612e664 added every .env to .gitignore 2022-08-02 12:51:24 +02:00
4633927204 moved from static DNS provider to a dynamic Docker variable and env file 2022-08-02 12:03:51 +02:00
64e726391a removed compose version, not needed anymore
(see https://docs.docker.com/compose/compose-file/#version-top-level-element)
2022-08-02 12:01:33 +02:00
4d4a578b78 variabilized more values, reorganized values in env.example file 2022-01-22 23:27:55 +01:00
39dbe048f5 added standard YAML three-dashes notation 2022-01-22 23:22:01 +01:00
310c237add renamed certificate file 2022-01-22 23:21:37 +01:00
4f46fdcdea removed config folder from .gitignore, added tls config file
actually that was a stupid idea, configs need to be tracked and version controlled
2022-01-15 23:46:54 +01:00
ccb8dee381 renamed repository in README.md 2022-01-15 23:40:46 +01:00
6 changed files with 62 additions and 37 deletions

5
.gitignore vendored
View File

@@ -1,3 +1,2 @@
.env /.env*
config /certs.json
le-certs.json

View File

@@ -1,3 +1,3 @@
# traefik.bjphoster.com # Træfik Deployment
Træfik deployment for reverse proxying all the infrastructure Træfik deployment for reverse proxying all the infrastructure

11
config/tls.yml Normal file
View File

@@ -0,0 +1,11 @@
---
tls:
options:
default:
minVersion: VersionTLS12
mintls13:
minVersion: VersionTLS13
compatible:
minVersion: VersionTLS11
supercompatible:
minVersion: VersionTLS10

View File

@@ -1,9 +1,7 @@
version: "3" ---
services: services:
traefik: traefik:
image: traefik:${TRAEFIK_VERSION} image: traefik:${TRAEFIK_VERSION}
container_name: ${TRAEFIK_CONTAINER_NAME}
restart: unless-stopped restart: unless-stopped
command: command:
# when debugging is needed # when debugging is needed
@@ -11,18 +9,17 @@ services:
# 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
- --certificatesresolvers.letsencrypt.acme.dnschallenge=true - --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.dnschallenge=true
- --certificatesresolvers.letsencrypt.acme.dnschallenge.provider=hetzner - --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.dnschallenge.provider=${TRAEFIK_DNSPROVIDER}
- --certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL} - --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.dnschallenge.resolvers=${TRAEFIK_DNSRESOLVERS}
- --certificatesresolvers.letsencrypt.acme.keytype=RSA4096 - --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.email=${LETSENCRYPT_EMAIL}
- --certificatesresolvers.letsencrypt.acme.storage=/le-certs.json - --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.keytype=RSA4096
- --certificatesresolvers.${TRAEFIK_CERTRESOLVER}.acme.storage=/certs.json
# we listen on both HTTP and HTTPS # we listen on both HTTP and HTTPS
- --entrypoints.http.address=:80 - --entrypoints.http.address=:80
- --entrypoints.https.address=:443 - --entrypoints.https.address=:443
# logging level # logging level
- --log.level=${TRAEFIK_LOGLEVEL} - --log.level=${TRAEFIK_LOGLEVEL}
# Træfik Pilot token (of course retrieved from dotenv)
- --pilot.token=${TRAEFIK_PILOT_TOKEN}
# we only use Docker (for now) # we only use Docker (for now)
- --providers.docker=true - --providers.docker=true
# and we want to manually specify exposed containers # and we want to manually specify exposed containers
@@ -31,34 +28,36 @@ services:
# should not need, but just in case, a folder for dynamic config files is also configured # should not need, but just in case, a folder for dynamic config files is also configured
- --providers.file.directory=/config - --providers.file.directory=/config
- --providers.file.watch=true - --providers.file.watch=true
environment: env_file:
- HETZNER_API_KEY=${HETZNER_API_KEY} - ${TRAEFIK_DNSPROVIDER_ENVFILE}
labels: labels:
# expose Træfik using Træfik (dashboard) # expose Træfik using Træfik (dashboard)
- traefik.enable=true - traefik.enable=${TRAEFIK_ENABLED}
# configure a global whitelist for my home - traefik.docker.network=${TRAEFIK_NETWORK}
# configure a global whitelist for accessing the Træfik dashboard
- traefik.http.middlewares.dashboard-whitelist.ipwhitelist.sourcerange=${TRAEFIK_DASHBOARD_WHITELIST} - traefik.http.middlewares.dashboard-whitelist.ipwhitelist.sourcerange=${TRAEFIK_DASHBOARD_WHITELIST}
# configure the global redirect middleware # configure a global middleware for redirecting HTTP to HTTPS
- 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
# configure a global middleware to harden security through HSTS
- traefik.http.middlewares.hsts.headers.stsSeconds=${TRAEFIK_STS_SECONDS}
- traefik.http.middlewares.hsts.headers.stsIncludeSubdomains=${TRAEFIK_STS_SUBDOMAINS}
- traefik.http.middlewares.hsts.headers.stsPreload=${TRAEFIK_STS_PRELOAD}
### Section HTTP ### Section HTTP
- traefik.http.routers.http-${TRAEFIK_ROUTER}.entrypoints=http - traefik.http.routers.http-${TRAEFIK_ROUTER}.entrypoints=http
# only some people can access the dashboard, hence protect it with it's whitelist
- traefik.http.routers.http-${TRAEFIK_ROUTER}.middlewares=dashboard-whitelist
# redirect Træfik dashboard to HTTPS only # redirect Træfik dashboard to HTTPS only
- traefik.http.routers.http-${TRAEFIK_ROUTER}.middlewares=http-to-https - traefik.http.routers.http-${TRAEFIK_ROUTER}.middlewares=${TRAEFIK_HTTP_MIDDLEWARES}
- traefik.http.routers.http-${TRAEFIK_ROUTER}.rule=Host(`${TRAEFIK_MATCHRULE}`) - traefik.http.routers.http-${TRAEFIK_ROUTER}.rule=${TRAEFIK_MATCHRULE}
- traefik.http.routers.http-${TRAEFIK_ROUTER}.service=api@internal - traefik.http.routers.http-${TRAEFIK_ROUTER}.service=api@internal
### Section HTTPS ### Section HTTPS
- traefik.http.routers.https-${TRAEFIK_ROUTER}.entrypoints=https - traefik.http.routers.https-${TRAEFIK_ROUTER}.entrypoints=https
# only some people can access the dashboard, hence protect it with it's whitelist
- traefik.http.routers.https-${TRAEFIK_ROUTER}.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_ROUTER}.rule=Host(`${TRAEFIK_MATCHRULE}`) - traefik.http.routers.https-${TRAEFIK_ROUTER}.middlewares=${TRAEFIK_HTTPS_MIDDLEWARES}
- traefik.http.routers.https-${TRAEFIK_ROUTER}.rule=${TRAEFIK_MATCHRULE}
- traefik.http.routers.https-${TRAEFIK_ROUTER}.service=api@internal - traefik.http.routers.https-${TRAEFIK_ROUTER}.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_ROUTER}.tls=true - traefik.http.routers.https-${TRAEFIK_ROUTER}.tls=${TRAEFIK_TLSENABLED}
- traefik.http.routers.https-${TRAEFIK_ROUTER}.tls.certresolver=letsencrypt - traefik.http.routers.https-${TRAEFIK_ROUTER}.tls.certresolver=${TRAEFIK_CERTRESOLVER}
networks: networks:
- traefik - traefik
ports: ports:
@@ -66,8 +65,8 @@ services:
- 443:443 - 443:443
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
- ./config:/config:ro - ${TRAEFIK_DYNAMIC}:/config:ro
- ./le-certs.json:/le-certs.json - ${TRAEFIK_CERTFILE}:/certs.json
networks: networks:
traefik: traefik:

1
env.dnsprovider.example Normal file
View File

@@ -0,0 +1 @@
HETZNER_API_KEY=

View File

@@ -1,15 +1,30 @@
TRAEFIK_VERSION=2.4 # General environment
TRAEFIK_CONTAINER_NAME=traefik.mydomain.com TRAEFIK_VERSION=latest
TRAEFIK_MATCHRULE=traefik.mydomain.com TRAEFIK_CERTRESOLVER=letsencrypt
TRAEFIK_ROUTER=traefik_mydomain_com
TRAEFIK_NETWORK=traefik-proxy
TRAEFIK_PILOT_TOKEN=
TRAEFIK_DASHBOARD_WHITELIST=1.2.3.4/24 TRAEFIK_DASHBOARD_WHITELIST=1.2.3.4/24
TRAEFIK_ENABLED=true
TRAEFIK_NETWORK=traefik
TRAEFIK_MATCHRULE=Host(`traefik.mydomain.com`)
TRAEFIK_ROUTER=traefik_mydomain_com
TRAEFIK_HTTP_MIDDLEWARES=dashboard-whitelist,http-to-https
TRAEFIK_HTTPS_MIDDLEWARES=dashboard-whitelist,hsts
# Security
TRAEFIK_TLSENABLED=true
TRAEFIK_STS_SECONDS=15552000
TRAEFIK_STS_SUBDOMAINS=true
TRAEFIK_STS_PRELOAD=true
# Certificate provider # Certificate provider
HETZNER_API_KEY= TRAEFIK_DNSPROVIDER=hetzner
TRAEFIK_DNSPROVIDER_ENVFILE=./.env.dnsprovider
TRAEFIK_DNSRESOLVERS=1.1.1.1:53,1.0.0.1:53
LETSENCRYPT_EMAIL=admin@mydomain.com LETSENCRYPT_EMAIL=admin@mydomain.com
# Debugging # Debugging
TRAEFIK_ACCESSLOG=false TRAEFIK_ACCESSLOG=false
TRAEFIK_LOGLEVEL=INFO TRAEFIK_LOGLEVEL=INFO
# Volumes
TRAEFIK_DYNAMIC=./config
TRAEFIK_CERTFILE=./certs.json