I have an apache serving one local app on "/
" with its static files on "/static
"
And another app with mod_proxy
:
ProxyPreserveHost On
ProxyPass "/example" "http://127.0.0.1:9090/"
ProxyPassReverse "/example" "http://127.0.0.1:9090/"
And this app does have static content on its own "/static
" but when it comes through the proxy taques te files from the first one.
¿Is there any way to serve "/static
" to eachone depending on were does the recuest comes from?
Best Answer
Given your example, I would expect the tomcat static files located at
http://127.0.0.1:9090/static
to be accessible underhttp://127.0.0.1/example/static
when using the proxy.Possible Solution 1
I think the best practice solution would be to change to use relative paths in the tomcat app instead of absolute path, so the static files used the latter path;
or server root relative;
and that would correctly serve the images e.g.
possible solution 2
Rename the apache static files to something else, and explicitly proxy the /static path to tomcat;
Also note:
Possibly hacky solution
Detect whether the request was initiated from the tomcat app by inspected the referer header;
(I didn't test that last solution, as it would seem just a novelty way of doing things...)