How To Rewrite Uri Nginx Reverse Proxy Using Proxy_pass?
I'm trying to use nginx to reverse proxy into kubernetes pods running various web apps. My issue is that I can only proxy when location is set to / and not /someplace I know the in
Solution 1:
Try adding the URL in your proxy location like this:
location = /app1/ {
proxy_pass http://10.82.5:80/;
}
Adding a trailing /
at the end of the proxy_pass forces nginx to strip the /app1
prefix from your requests while sending it to the backend.
Explanation on how it works on the official nginx page: http://nginx.org/en/docs/http/ngx_http_proxy_module.html?&_ga=1.74997266.187384914.1443061481#proxy_pass
If the proxy_pass directive is specified with a URI, thenwhen a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive:
Post a Comment for "How To Rewrite Uri Nginx Reverse Proxy Using Proxy_pass?"