I'm trying to put a reverse proxy in front of a few internal web services.
Nginx is setup and working properly to serve request. If I only serve one location /
in my conf file, it loads that proxy_pass target successfully ie:
location / {
proxy_pass https://internal.ip:port/;
}
Browsing to the https://public_proxy_address/ loads that internal resource perfectly.
However, since I have multiple internal applications, I want to proxy all of them through nginx. So, in my testing I have changed the conf to as follows:
location /app1 {
proxy_pass https://internal.ip:port/;
}
With this in place, I get the main/default internal app index page, but the view source shows me that no link stylesheets, js, or other resources are being re-written. Therefore the entire contents of the page, fails to load. In Apache, I would probably write a proxyhtmlurlmap ^/resource/ /app1/resource R
. I cannot find any way to achieve this in nginx though.
I have also tried this, to no avail:
location /app1 {
rewrite /resource(.*?) /app1/resource$1 break;
proxy_pass https://internal.ip:port/;
}
How do I get nginx to properly prepend the target location (app1) to the requested resource urls so that they load?