-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RedirectRegex broken since update to v3.0 #10690
Comments
I have the same issue after migrating from Traefik v2 to Traefik 3.0, e.g. also with a simple redirect from Config:
There was no redirect, the webpage could not be accessed anymore. There were no docker logs for the traefik container. |
But what did work on Traefik v3 was:
|
Sorry for the late answer. I tried to reproduce the issue with the following docker-compose: version: '3.8'
services:
hub:
image: traefik:v3.0
command:
- --providers.docker
- --log.level=DEBUG
- --api.insecure
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "0.0.0.0:80:80"
- "0.0.0.0:8080:8080"
whoami:
image: traefik/whoami
labels:
traefik.http.routers.whoami.rule: Host(`mingw-w64.org`) || Host(`mingw-w64.net`) || Host(`www.mingw-w64.net`)
traefik.http.routers.whoami.middlewares: redir
traefik.http.middlewares.redir.redirectregex.regex: ^http(s?)://(?:www[.])?mingw-w64[.](?:org|net)/(.*)$$
traefik.http.middlewares.redir.redirectregex.replacement: http$${1}://www.mingw-w64.org/$${2} $ curl -Iv http://127.0.0.1 -H "Host: mingw-w64.org"
* Trying 127.0.0.1:80...
* Connected to 127.0.0.1 (127.0.0.1) port 80
> HEAD / HTTP/1.1
> Host: mingw-w64.org
> User-Agent: curl/8.6.0
> Accept: */*
>
< HTTP/1.1 307 Temporary Redirect
HTTP/1.1 307 Temporary Redirect
< Location: http://www.mingw-w64.org/
Location: http://www.mingw-w64.org/
< Date: Tue, 28 May 2024 08:24:08 GMT
Date: Tue, 28 May 2024 08:24:08 GMT
< Content-Length: 18
Content-Length: 18
<
* Connection #0 to host 127.0.0.1 left intact And it seems is working as expected could you please provide a complete reproductible use case |
Thank you for your answer, @mmatur. Was the above general |
@pbek with the following docker-compose version: '3.8'
services:
hub:
image: traefik:v3.0
command:
- --providers.docker
- --log.level=DEBUG
- --api.insecure
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "0.0.0.0:80:80"
- "0.0.0.0:8080:8080"
whoami:
image: traefik/whoami
labels:
traefik.http.routers.whoami.rule: Host(`www.whoami.localhost`)
traefik.http.routers.whoami.middlewares: bekerle-web-2022-www
traefik.http.middlewares.bekerle-web-2022-www.redirectregex.regex: ^(https?://)www.(.*)$$
traefik.http.middlewares.bekerle-web-2022-www.redirectregex.replacement: $${1}$${2} $ curl -Iv http://127.0.0.1 -H "Host: www.whoami.localhost"
* Trying 127.0.0.1:80...
* Connected to 127.0.0.1 (127.0.0.1) port 80
> HEAD / HTTP/1.1
> Host: www.whoami.localhost
> User-Agent: curl/8.6.0
> Accept: */*
>
< HTTP/1.1 307 Temporary Redirect
HTTP/1.1 307 Temporary Redirect
< Location: http://whoami.localhost/
Location: http://whoami.localhost/
< Date: Tue, 28 May 2024 09:11:00 GMT
Date: Tue, 28 May 2024 09:11:00 GMT
< Content-Length: 18
Content-Length: 18
<
* Connection #0 to host 127.0.0.1 left intact I'm not able to reproduce either. |
Oh, I tried again on my server and I can confirm that the traefik v3.0.1 docker image solved the issues! 🥳 |
It still fails here with v3.0.1: $ curl -Iv http://mingw-w64.org
* Host mingw-w64.org:80 was resolved.
* IPv6: (none)
* IPv4: 178.63.98.68
* Trying 178.63.98.68:80...
* Connected to mingw-w64.org (178.63.98.68) port 80
> HEAD / HTTP/1.1
> Host: mingw-w64.org
> User-Agent: curl/8.8.0
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< Date: Tue, 28 May 2024 12:33:42 GMT
Date: Tue, 28 May 2024 12:33:42 GMT
< Content-Length: 19
Content-Length: 19
<
* Connection #0 to host mingw-w64.org left intact |
@lazka you got a 404 answer probably due to the change on
I saw in your labels # https
- "traefik.http.routers.mingw-w64-secure.rule=Host(`mingw-w64.org`, `mingw-w64.net`, `www.mingw-w64.net`)" It needs to be replace by # https
- "traefik.http.routers.mingw-w64-secure.rule=Host(`mingw-w64.org`) || Host(`mingw-w64.net`) || Host(`www.mingw-w64.net`)" |
Welcome!
What did you do?
I have the following RedirectRegex config: https://github.com/msys2/msys2-main-server/blob/8330fd44f4fdf76d27200e995fb8494a4006e6c3/docker-compose.yml#L153-L154
This resulted in "https://mingw-w64.org" being redirected to "https://www.mingw-w64.org", among other cases.
Since the update to v3.0 from v2.11.2 this no longer works and requests using "https://mingw-w64.org" no longer get redirected. I've confirmed that downgrading to 2.11 makes things work again.
I couldn't find anything in the migration guide regarding any changes for RedirectRegex, so I'm filing this here.
What did you see instead?
No redirect happening.
What version of Traefik are you using?
3.0.0
What is your environment & configuration?
See the linked docker-compose.yml above
If applicable, please paste the log output in DEBUG level
No response
The text was updated successfully, but these errors were encountered: