Hey all, I am currently on school break and have spent almost 6 full days (and several nights) on traefik now. I have a whole configuration in mind, but it just doesn't want to work. It seems to be a certificate problem, since traefik does not seem to create any wildcard wertificate at all.
So this is my traefik.yml:
#IEDEREEN KOMT BINNEN VIA HHTPS MET CROWDSEC-BEVEILIGING
entryPoints:
http:
address: :80
http:
redirections:
entryPoint:
to: https
scheme: https
https:
address: :443
http:
tls:
certResolver: letsEncrypt
domains:
- main: "mysubdomain.duckdns.org"
sans:
- "*.mysubdomain.duckdns.org"
middlewares:
- crowdsec-bouncer@file # Create the HTTPS entrypoint on port 443
#ANDERE SHIT
serversTransport:
insecureSkipVerify: true
global:
checknewversion: true # Periodically check if a new version has been released.
sendanonymoususage: false # Periodically send anonymous usage statistics.
#VERBINDING MET DE DOCKER LABELS
providers:
docker:
endpoint: "unix:///var/run/docker.sock" # Listen to the UNIX Docker socket
exposedByDefault: false # Only expose container that are explicitly enabled (using label traefik.enabled)
# network: "traefik-net" # Default network to use for connections to all containers.
defaultRule: "Host(`{{ if index .Labels \"com.docker.compose.service\" }}{{ index .Labels \"com.docker.compose.service\" }}{{ else }}{{ .Name }}{{ end }}.jvr2.duckdns.org`)" #EERST IF OPTIE IS VOOR CONTAINERS GEMAAKT MET COMPOSE --> GEBRUIKT CONTAINER-NAAM
file:
filename: "/etc/traefik/config.yml" # Link to the dynamic configuration
watch: true # Watch for modifications
providersThrottleDuration: 10 # Configuration reload frequency
#LET'S ENCRYPT CERTIFICATEN
certificatesResolvers: # Certificate Resolvers are responsible for retrieving certificates from an ACME server
letsEncrypt: # See https://doc.traefik.io/traefik/https/acme/#certificate-resolvers
acme:
email: "mymailbox@hotmail.com" # Email address used for registration
storage: "/etc/traefik/acme/acme.json" # File or key used for certificates storage
# caServer: https://acme-v02.api.letsencrypt.org/directory # prod (default)
caServer: https://acme-staging-v02.api.letsencrypt.org/directory # staging
dnsChallenge:
provider: duckdns
disablePropagationCheck: true
delayBeforeCheck: 200
resolvers:
- "1.1.1.1:53"
- "8.8.8.8:53"
#LOGS VOOR CROWDSEC
log:
level: "INFO"
filePath: "/var/log/traefik/traefik.log"
accessLog:
filePath: "/var/log/traefik/access.log"
This is my config.yml:
#MIDDLEWARES
http:
middlewares:
#PRESETS: LOKAAL, AUTH, AUTHAPP, PUBLIEK, PUBLIEKBE
#PUBLIEKBE --> Use with traefik.http.routers.myRouter.middlewares: "publiekbe@file"
publiekbe:
chain:
middlewares:
- default-security-headers
- error-pages
- BE-GeoBlock
#LOKAAL --> Use with traefik.http.routers.myRouter.middlewares: "lokaal@file"
lokaal:
chain:
middlewares:
- default-security-headers
- error-pages
- BE-GeoBlock
- iplokaal
#REST MOET IK NOG MAKEN
#VERSCHILLENDE MIDDLE-WARES DEFINIËREN
iplokaal:
ipAllowList:
sourceRange:
- "192.168.1.0/24"
crowdsec-bouncer:
forwardauth:
address: http://bouncer-traefik:8080/api/v1/forwardAuth
trustForwardHeader: true
traefikAuth: # A basic authentification middleware, to protect the Traefik dashboard to anyone except myself
basicAuth: # Use with traefik.http.routers.myRouter.middlewares: "traefikAuth@file"
users:
- "admin:hashedpassword"
default-security-headers: # Use with traefik.http.routers.myRouter.middlewares: "default-security-headers@file"
headers:
browserXssFilter: true # X-XSS-Protection=1; mode=block
contentTypeNosniff: true # X-Content-Type-Options=nosniff
forceSTSHeader: true # Add the Strict-Transport-Security header even when the connection is HTTP
frameDeny: true # X-Frame-Options=deny
referrerPolicy: "strict-origin-when-cross-origin"
sslRedirect: true # Allow only https requests
stsIncludeSubdomains: true # Add includeSubdomains to the Strict-Transport-Security header
stsPreload: true # Add preload flag appended to the Strict-Transport-Security header
stsSeconds: 63072000 # Set the max-age of the Strict-Transport-Security header (63072000 = 2 years)
BE-GeoBlock:
plugin:
geoblock:
silentStartUp: false
allowLocalRequests: true
logLocalRequests: false
logAllowedRequests: false
logApiRequests: false
api: "https://get.geojs.io/v1/ip/country/{ip}"
apiTimeoutMs: 500
cacheSize: 25
forceMonthlyUpdate: true
allowUnknownCountries: false
unknownCountryApiResponse: "nil"
countries:
- BE
error-pages: # Serve the error pages when the status is included inside the following ranges
errors: # Use with traefik.http.routers.myRouter.middlewares: "error-pages@file"
query: "erreur{status}/"
service: traefik-error-pages
status:
- "403-404"
- "500"
- "503"
services:
# Error pages
traefik-error-pages:
loadBalancer:
servers:
- url: "https://www.usherbrooke.ca/error-pages/"
#DEFINIËREN VAN TLS VERSIES: MODERN, INTERMEDIATE en OLD
tls: # See https://doc.traefik.io/traefik/https/tls/
options:
# To use with the label "traefik.http.routers.myrouter.tls.options=modern@file"
modern:
minVersion: "VersionTLS13" # Minimum TLS Version
sniStrict: true # Strict SNI Checking
# To use with the label "traefik.http.routers.myrouter.tls.options=intermediate@file"
intermediate:
cipherSuites:
- "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
- "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
- "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
- "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
- "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305"
- "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
minVersion: "VersionTLS12" # Minimum TLS Version
sniStrict: true # Strict SNI Checking
# To use with the label "traefik.http.routers.myrouter.tls.options=old@file"
old:
cipherSuites:
- "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
- "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
- "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
- "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
- "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305"
- "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
- "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
- "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
- "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"
- "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"
- "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"
- "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"
- "TLS_RSA_WITH_AES_128_GCM_SHA256"
- "TLS_RSA_WITH_AES_256_GCM_SHA384"
- "TLS_RSA_WITH_AES_128_CBC_SHA256"
- "TLS_RSA_WITH_AES_128_CBC_SHA"
- "TLS_RSA_WITH_AES_256_CBC_SHA"
- "TLS_RSA_WITH_3DES_EDE_CBC_SHA"
minVersion: "TLSv1" # Minimum TLS Version
sniStrict: true # Strict SNI Checking
# Generated 2021-08-12, Mozilla Guideline v5.6, Traefik 2.4.8
# https://ssl-config.mozilla.org/#server=traefik&version=2.4.8&config=old&guideline=5.6
# https://ssl-config.mozilla.org/#server=traefik&version=2.4.8&config=intermediate&guideline=5.6
And this is my traefik docker container (it was a portainer stack, but i changed some things in the GUI):
Portainer:
image: traefik:v3.1
ports: 80:80 443:443 8080:8080
command: 'traefik' '--log.level=DEBUG'
entrypoint: /entrypoint.sh
volumes:
/var/run/docker.sock:/var/run/docker.sock
/etc/localtime:/etc/localtime
traefik_config:/etc/traefik
traefik_traefik-logs:/var/log/traefik
network: traefik-net
env:
TZ=Europe/Amsterdam
DUCKDNS_TOKEN=MYDUCKDNSTOKEN
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin (something that came automatic, I think)
labels:
traefik.http.routers.traefik-secure.service=api@internal
restart-policy: unless-stoped
As an example, I then give my docker containers the following labels in portainer:
A CONTAINER PUBLICLY ACCESSIBLE FROM BELGIUM
traefik.enable=true
traefik.http.routers.rallly.entrypoints=https
traefik.http.routers.rallly.middlewares=publiekbe@file
traefik.http.routers.rallly.tls.options=modern@file
traefik.http.services.rallly.loadbalancer.server.port=3000
network: traefik-net
A CONTAINERS THAT CAN ONLY BE ACCESSED LOCALLY
traefik.enable=true
traefik.http.routers.stirling-pdf.entrypoints=https
traefik.http.routers.stirling-pdf.middlewares=local@file
traefik.http.routers.stirling-pdf.tls.options=modern@file
network: traefik-net
--> This only seems to work half the time due to certificate issues. Traefik often does not create certificates, and certainly not wildcard certificates (which is what it is supposed to do)! Could someone please relieve me of my mounting frustration? Thanks in advance!!!!