just plain ol' not working.
Global HTTPS redirect works. but not example.com > www.example.com
here is traefik config:
version: "3.3"
networks:
public:
external: true
services:
traefik:
image: "traefik:v2.9"
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.swarmMode=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entryPoints.websecure.address=:443"
- "--providers.docker.network=public"
labels:
- "traefik.http.routers.redirect-router.middlewares=redirect-regex"
- "traefik.http.middlewares.redirect-regex.redirectregex.regex=^https://example.com/(.*)"
- "traefik.http.middlewares.redirect-regex.redirectregex.replacement=https://www.example.com/$${1}"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
public:
aliases:
- traefik
deploy:
mode: global
and example.com / www.example.com service
version: "3.8"
networks:
public:
external: true
services:
nginx:
image: "nginx:stable-alpine"
deploy:
<<: *default_deploy
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.rule=Host(`example.com`) || Host(`www.example.com`)"
- "traefik.http.routers.nginx.entrypoints=websecure"
- "traefik.http.routers.nginx.tls.certresolver=default"
- "traefik.http.services.nginx.loadbalancer.server.port=80"
- "traefik.http.routers.nginx.tls=true"
- "traefik.docker.network=public"
networks:
public:
aliases:
- nginx
Global HTTPS redirect works. but not example.com > www.example.com
I read here (Redirecting to an external domain with traefik | Jens Knipper) that "multiple levels of redirects do not work. If you also want to do a global https-redirect and www redirect for your domain you are not able to do both". Is this true, please dear god, say it isn't so.