k8s nginx ingress rewrite-target annotation not working as expected k8s nginx ingress rewrite-target annotation not working as expected nginx nginx

k8s nginx ingress rewrite-target annotation not working as expected


You are misunderstanding the example. With your configuration requests to the rewrite target / will be rewritten to /config/, not the other way around. So you need to switch paths: use /config as rewrite target, and set the / path in the rule.

So the rewrite target is always where the external requests go to, the rule path where the requests to the service/pod go to.


apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: my-ingress  annotations:    kubernetes.io/ingress.class: "nginx"    nginx.ingress.kubernetes.io/rewrite-target: /$1spec:  rules:    - http:        paths:        - path: /config/(.+)          backend:            serviceName: api-gateway            servicePort: web