Hello,
I've been working on setting up Traefik as a reverse proxy in a Docker Swarm environment but am encountering several issues that I can't seem to resolve. My main problem is that traffic isn't being redirected to my whoami
service, and depending on the configurations I try, I sometimes receive errors stating that ports are not found for either Traefik or whoami
.
I'm including my docker-compose.yml and Traefik configuration files below. I would greatly appreciate it if someone could review my configuration and point out what I might be doing wrong or suggest how I can get this setup working correctly.
docker-compose
version: "3"
services:
traefik:
networks:
- booker
image: "traefik:v3.0"
command:
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--providers.docker.exposedbydefault=false"
- "--log.level=DEBUG"
- "--accesslog=true"
- "--api.debug=true"
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/etc/traefik/traefik.yml:/etc/traefik/traefik.yml"
- /etc/traefik/dyno/:/dynconf
- "/etc/traefik/certs/cert.crt:/cert.crt"
- "/etc/traefik/private/p.key:/p.key"
#deploy:
# labels:
#- "traefik.docker.network=booker"
#- "traefik.http.services.traefik.loadbalancer.server.port=8080"
whoami:
networks:
- booker
image: "traefik/whoami"
ports:
- "8080:80"
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`helpme.ws`)"
- "traefik.http.services.whoami.loadbalancer.server.port=:80"
- "traefik.http.routers.whoami.entrypoints=websecure"
#- traefik.http.middlewares.mywwwredirect.redirectregex.regex=^https://www\.(.*)
#- traefik.http.middlewares.mywwwredirect.redirectregex.replacement=https://$${1}
#- traefik.http.routers.mywhoami.middlewares=mywwwredirect
networks:
booker:
external: true
traefik.yml
log:
level: debug
providers:
swarm: {}
#endpoint: "tcp://127.0.0.1:2377"
file:
directory: /dynconf
watch: true
entryPoints:
web:
address: ":80"
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: ":443"
dyn1.yml
tls:
certificates:
- certFile: "/cert.crt"
keyFile: "/p.key"
stores:
- default