-
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
rewrite-target invalid for kubernetes ingress on root path #5990
Comments
Hello @seboudry, You gave an example of what you expected to happen:
But that is not what you see:
And what you expect is not how nginx handles it either:
You need to pay close attention to whether your request has a trailing slash. You have configured the rewrite-target NOT to have a trailing slash:
And your application doesn't appear to listen on that path:
What happens if you use: |
Hi @dtomcej ! Here's my working Nginx ingress definition: apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress-nginx
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /app/
spec:
rules:
- host: app.my-domain.fr
http:
paths:
- backend:
serviceName: my-app
servicePort: http So indeed the target have a trailing slash and app listen on Using Traefik, if I add a trailing slash with
If I remove
So it seems the fix is to have the trailing slash on |
Hello @seboudry This behavior was last changed almost a year and a half ago with this PR: Can you please confirm that you are expecting different behavior than that? We manually strip the slash off the right: https://github.com/containous/traefik/blame/a8393faf0ae6714e9d545051011624738a9eb2b7/provider/kubernetes/kubernetes.go#L676 |
There might be an edge case when the path matched is |
Yes, It works fine when path contains something without trailing slash ( Just giving a hand on Traefik since this week ;) |
Ok. So it is the edge case. Will look at making a PR. Just to confirm, the case that we are wanting to implement is: apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress-traefik
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/rewrite-target: /app/
spec:
rules:
- host: app.my-domain.fr
http:
paths:
- backend:
serviceName: my-app
servicePort: http or apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/rewrite-target: /app/
spec:
rules:
- host: app.my-domain.fr
http:
paths:
- path: /
backend:
serviceName: my-app
servicePort: http should both result in rules that forward these requests:
|
Exactly! And using the test requests from previous PR:
Thanks for the quick consideration of this! 👍 |
@seboudry, feel free to test with this PR to see if it works for you (it should). |
PR tested OK ;) |
Closed by #6005. |
Do you want to request a feature or report a bug?
Bug
What did you do?
Creating an Ingress resource on a subdomain having only one rule on
/
that point to a backend handling requests on/app
.What did you expect to see?
Traefik to send all requests with URLs on domain with
app.my-domain.fr
to my backend on path:/
->/app/
/foo/
->/app/foo/
Same as
nginx.ingress.kubernetes.io/rewrite-target
behavior.What did you see instead?
with a 404 status code.
But, request on
https://app.my-domain.fr//
(notice the additional/
at end) give a 200 with expected response.traefik version
In Kubernetes, installed with Helm chart stable/traefik v1.82.3
What is your environment & configuration (arguments, toml, provider, platform, ...)?
Route rule (on dashboard):
The text was updated successfully, but these errors were encountered: