How to implement absolute path forwarding request using ingress-nginx

8/21/2019

I am trying to use ingress-nginx to implement nginx's proxy_pass specified with a URI to distribute different requests to different backend services. How do I configure it?

The version of ingress-nginx I am using is 0.22. I tried using the nginx.ingress.kubernetes.io/rewrite-target annotation, but it is not the effect I want.

I want to use ingress-nginx to implement the following nginx configuration, the proxy_pass directive is specified with a URI:

location /asset/api {
    proxy_pass http://asset_api/;
}
-- xudahuo
kubernetes
nginx

1 Answer

8/22/2019

My fault, using nginx.ingress.kubernetes.io/rewrite-target can achieve the above functions:

Routing:

example.com/asset/web/(.*)

Then use the ingress annotation feature:

nginx.ingress.kubernetes.io/rewrite-target: '$1'
-- xudahuo
Source: StackOverflow