Ingress.kubernetes.io/rewrite-target not working

Hi all,

I am trying to setup an Ingress on Kubernetes but I am facing a problem. I need to rewrite the request before it gets passed to the service and I saw that there is a kubernetes annotation that should handle this (rewrite-target) but it is not being considered.
I have the following ingress configuration that points to a service that is a simple image based on nginx with static content:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /mni-ui
        backend:
          serviceName: mni-webui
          servicePort: 80

and here is the output on nginx that shows that the request is being passed with the leading /mni-ui that I wished was removed from the request:

2017/08/16 16:16:09 [error] 6#6: *1948 open() "/usr/share/nginx/html/mni-ui" failed (2: No such file or directory), client: 10.42.141.21, server: localhost, request: "GET /mni-ui HTTP/1.1", host: "10.114.173.22"

Is it the normal behaviour? Isn’t the rewrite-target annotation supported on k8s on rancher? Btw I am using RancherOS 1.6.5

regards,
Rafael

1 Like