Add sub_filter module to nginx
Summary
Sub_filter module should be added to the bundled nginx server in order to be able to rewrite body links of proxied requests.
Proposal
Problem
I am trying to serve different web apps via reverse proxy. For now we can inject custom nginx config as seen here.
The apps should be organized so:
| public url | Content |
|---|---|
| mydomain.com/ | Home/Menu to navigate to the apps |
| mydomain.com/app1 | app1 |
| mydomain.com/app2 | app2 |
Now with the correct nginx config I can navigate to the apps, but they will have "bad links" since they will point to mydomain.com/*, which will make nginx to return always mydomain.com/,i.e. the Home/Menu to the apps.
So if in app1 is a relative link like /users it will point to mydomain.com/users/ and not to mydomain.com/app1/users/.
Possible solution
Using nginx's sub_filter module we should be able to rewrite the body links.
This way the links of the apps can be rewritten via:
sub_filter "http://mydomain.com" "http://mydomain.com/appX"
sub_filter_once off;
In the example above the app1 will have a correct link to /users, since it will be rewritten from mydomain.com/users to mydomain.com/app1/users