Hi all,
we currently use nginx-proxy and would like to move to traefik as we heard so much appraisal. I spent multiple hours now researching, reading and trying to put the right configuration together but I am failing miserably, even on a single host.
What I got:
- External TCP Load-Balancer forwarding with Proxy-Protocol (to get request IP)
(using plain TCP forward on all used ports with proxy protocol) - Traefik in Docker
- WebApp in Docker
- Wildcard SSL certificate
What I would like to achive:
- Forward WebApp port 80 to 443
- Run WepApp on port 443 with fixed wildcard certificate
- Run dashboard on port 8443 with same fixed wildcard certificate and password
Static config:
# /data/traefik/traefik.yml
# Entrypoints
entryPoints:
web:
address: :80
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: :443
internal:
address: :8080
internalsecure:
address: :8443
# Docker configuration backend
providers:
docker:
defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
file:
directory: /etc/traefik/dynamic
# API and dashboard configuration
api:
dashboard: true
insecure: true
Dynamic config:
# /data/traefik/dynamic/traefik_dynamic.yml
http:
routers:
api:
rule: Host(`traefik.domain.eu`)
service: api@internal
entryPoints:
- internal
middlewares:
- auth
middlewares:
auth:
basicAuth:
users:
- "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/" # user: test password:test
tls:
stores:
default:
defaultCertificate:
certFile: /etc/traefik/certs/domain.eu.crt
keyFile: /etc/traefik/certs/domain.eu.key
Docker Traefik:
docker run \
--name traefik \
--restart always \
--publish 80:80 \
--publish 443:443 \
--publish 8080:8080 \
--publish 8888:8888 \
-v /data/traefik:/etc/traefik \
-v /data/certs:/etc/traefik/certs \
-v /var/run/docker.sock:/var/run/docker.sock \
--detach traefik:v2.4
Docker WebApp:
docker run \
--name whoami \
--label "traefik.enable=true" \
--label 'traefik.http.routers.whoami.rule=Host(`whoami.domain.eu`)' \
--label "traefik.http.routers.whoami.entrypoints=websecure" \
--detach containous/whoami
Various questions arise:
- Will ProxyProtokoll be recognized by default?
- Will it run like this without docker compose?
- How do I add the wildcard cert to the docker provider?
- How do I add the wildcard cert to the dashboard?