Kubernetes ingress not working on redirect on some path like "/myapp", but only working for "/" Kubernetes ingress not working on redirect on some path like "/myapp", but only working for "/" kubernetes kubernetes

Kubernetes ingress not working on redirect on some path like "/myapp", but only working for "/"


Ingress version 0.22.0 or higher has changed the way how rewrite-target works.You'll need to regex-match the path and add it to the rewrite-target.

nginx.ingress.kubernetes.io/rewrite-target: /$2......  rules:  - host: rewrite.bar.com    http:      paths:      - backend:          serviceName: http-svc          servicePort: 80        path: /something(/|$)(.*)

Refer to changelog here.How to article here


I'm thinking

- path: /myapp/

matches your app at http://myapp/myapp/

So if I have a definition:

  - host: app.example.com    http:      paths:      - path: /myapp

This would be http://app.example.com/myapp


if you want to use http://myapp/ps/app/ui/?pid=201 you need to:

  • make sure that your operating system translates myapp to a IP address where your ingress controller is listening
  • add the host myapp to the ingress
  • you can leave the path empty (assuming that your application is handling the complete /ps/app/ui/?pid=201 path)

This results in

rules:  - host: myapp    http:      paths:      - backend:          serviceName: ps-app-ui          servicePort: 8000

This ingress will forward all traffic to the host myapp to your service