I know, there was many topics about www <-> non-www redirection.
Checked them all, but still can't make it work.
My docker-compose.yml
file.
version: '3.8'
services:
traefik:
image: traefik
command:
- --entrypoints.web.address=:80
- --providers.docker
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
whoami:
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`example.com`) || Host(`www.example.com`)"
- "treafik.http.middlewares.www-redirect.redirectregex.regex=^http://www.example.com/(.*)"
- "traefik.http.middlewares.www-redirect.redirectregex.replacement=http://example.com/$${1}"
- "traefik.http.routers.whoami.middlewares=www-redirect"
I need to make redirection from www.example.com
to example.com
.
But instead every request is redirected to something like http://example.com/hhttp://example.com/thttp://example.com/thttp://example.com/phttp://example.com/:http://example.com//http://example.com...
many times (loop).
What is wrong with my code?