I am looking to reverse proxy one url/path to different ports on an end point that represent different servers hosting their own web apps.
I have the proxy_pass working, but the static files fail because the resources are relative their instance.
I have for example - server_name = myproxy.com:
location /app1/{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}
location /app2/{
proxy_pass: http://192.168.1.1:8081/;
proxy_set_header Host 192.168.1.2;
}
location /{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}
The reverse-proxy works great as mentioned, except for the static files associated with the app2. App1 static files work fine, but App2 static files result in a 404. Which make sense, because App1 resource files are located at /assets/app1.css
this works because I have a redirect for location /
in place that resolves back to App1 but App2 resource files, which are totally different /assets/app2.css
result in 404.
So, is there a way to rewrite App2 static requests from /assets/app2.css
to their respective proxy location? something like:
location /app1/{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}
location /app2/{
proxy_pass: http://192.168.1.1:8081/;
proxy_set_header Host 192.168.1.2;
*rewrite app2 static urls frome /assets/* to /app2/assets/*
}
location /{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}