I would like to create a global www to non www middleware, I configured it but when I look into the dashboard it doesn't show up under middlewares, and the redirect also doesn't work, so I think traefik doesn't recognize the middelware at all.
This is my config, under trafik - labels I added this:
labels:
- "traefik.http.middlewares.nonwww.redirectregex.regex=^https?://(?:www.)?(.+)"
- "traefik.http.middlewares.nonwww.redirectregex.replacement=https://$${1}"
and this is the config for my domain, what I want to achieve is that www redirects to non-www
r1:
image: traefik/whoami
command:
- "--port=8084"
labels:
- "traefik.enable=true"
- "traefik.http.routers.r1.rule=Host(`mydomain.tld`) || Host(`www.mydomain.tld`)"
- "traefik.http.routers.r1.entrypoints=websecure"
- "traefik.http.routers.r1.tls=true"
- "traefik.http.routers.r1.tls.certresolver=myresolver"
- "traefik.http.services.r1.loadbalancer.server.port=8084"