# Traefik Ingress with k3s / rewrite-target issue

**URL:** <https://community.traefik.io/t/traefik-ingress-with-k3s-rewrite-target-issue/12736>\
**Category:** Traefik v2\
**Tags:** kubernetes-ingress\
**Created:** [December 16, 2021, 11:36am UTC](https://community.traefik.io/t/traefik-ingress-with-k3s-rewrite-target-issue/12736 "2021-12-16T11:36:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MeherHihi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/meherhihi/32/4639_2.png) [@MeherHihi](https://community.traefik.io/u/MeherHihi)\
**Post date:** [December 16, 2021, 11:36am UTC](https://community.traefik.io/t/traefik-ingress-with-k3s-rewrite-target-issue/12736/1 "2021-12-16T11:36:59Z")

</div>

Hello,

I have an issue with the "rewrite-target" using traefik as ingress controller on a k3s cluster.

Below is my ingress.yaml:

```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.

---

<div class="post-metadata">

**Author:** ![stevelipinski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stevelipinski/32/4749_2.png) [@stevelipinski](https://community.traefik.io/u/stevelipinski)\
**Post date:** [January 9, 2022, 5:14pm UTC](https://community.traefik.io/t/traefik-ingress-with-k3s-rewrite-target-issue/12736/5 "2022-01-09T17:14:37Z")

</div>

Can confirm - same problem.  
Not sure if it's a traefik problem or something coming from k3s/rancher...

---

<div class="post-metadata">

**Author:** ![tommoulard](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tommoulard/32/2997_2.png) [@tommoulard](https://community.traefik.io/u/tommoulard)\
**Post date:** [January 21, 2022, 9:27am UTC](https://community.traefik.io/t/traefik-ingress-with-k3s-rewrite-target-issue/12736/6 "2022-01-21T09:27:53Z")

</div>

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](https://doc.traefik.io/traefik/routing/providers/kubernetes-ingress/#annotations)

But your goal can be achieved using the [StipPrefix](https://doc.traefik.io/traefik/middlewares/http/stripprefix/) middleware.

Edit: As a side note, k3d used, [until recently](https://github.com/k3s-io/k3s/releases/tag/v1.21.0+k3s1), 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.

---

<div class="post-metadata">

**Author:** ![alexdresko](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/alexdresko/32/5224_2.png) [@alexdresko](https://community.traefik.io/u/alexdresko)\
**Post date:** [April 15, 2022, 8:18pm UTC](https://community.traefik.io/t/traefik-ingress-with-k3s-rewrite-target-issue/12736/7 "2022-04-15T20:18:45Z")

</div>

@tommoulard Sorry to bother, but this answer is a little vague to me.

> Edit: As a side note, k3d used, [until recently](https://github.com/k3s-io/k3s/releases/tag/v1.21.0+k3s1), 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](https://doc.traefik.io/traefik/routing/providers/kubernetes-ingress/#on-ingress) not have `traefik.ingress.kubernetes.io/rewrite-target`, but [this page](https://doc.traefik.io/traefik/v1.7/configuration/backends/kubernetes/) does? I don't understand the difference between those two pages.
