Hello,
I have an issue with the "rewrite-target" using traefik as ingress controller on a k3s cluster.
Below is my ingress.yaml:
apiVersion: networking.kubernetes.io/v1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: traefik
name: test-nginx-ingress
spec:
rules:
- http:
paths:
- backend:
service:
name: test-nginx
port:
number: 80
path: /mywebapp
pathType: Prefix
As result, I have a response 404 from nginx due to a bad context as the rewrite-target seems not working and the request is sent with /mywebapp.
Thank you in advance for your responses.
Can confirm - same problem.
Not sure if it's a traefik problem or something coming from k3s/rancher...
Hello @MeherHihi, @stevelipinski,
Traefik does not support the traefik.ingress.kubernetes.io/rewrite-target
annotation. See the list of available annotations here: Kubernetes Ingress - Traefik
But your goal can be achieved using the StipPrefix middleware.
Edit: As a side note, k3d used, until recently, the v1.7.x version of traefik which does not have the same annotation.
Thus, when using such annotation, take a close look at the annotations supported by the version of traefik that you use.
1 Like
@tommoulard Sorry to bother, but this answer is a little vague to me.
Edit: As a side note, k3d used, until recently , the v1.7.x version of traefik which does not have the same annotation.
Are you saying that k3d now supports traefik.ingress.kubernetes.io/rewrite-target
?
Also, why does this page not have traefik.ingress.kubernetes.io/rewrite-target
, but this page does? I don't understand the difference between those two pages.