Apache reverse proxy – missing content

apache-2.4centos7reverse-proxy

here is my apache reverse proxy conf:

ProxyHTMLEnable On
ProxyHTMLExtended On
SetOutputFilter INFLATE;proxy-html;DEFLATE
ProxyHTMLInterp On
ProxyPass / http://10.208.202.2:8762/abc/
ProxyPassReverse / http://10.208.202.2:8762/abc/


ProxyPreserveHost On
RequestHeader set Authorization "Basic"
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"

The thing is when I enter / on my server some content is missing. For example css, some .css is supposed to be GET from /something/css/wro.css As I assume in this case content is not being downloaded because proxy actually tries to get it from /abc/something/css/wro.css which is wrong and it returns 404.
So i have tried to add:

ProxyPass /something http://10.208.202.2:8762/something/
ProxyPassReverse /something http://10.208.202.2:8762/something/

But this still does not do the trick, there is still the same css content missing.
Also I dont' see adding every location on the server manually to the configuration as a good idea. I have added proxy html mod, but it doesnt seem to do the job here.
Any suggestions what can I do, to make this work without adding proxypass entry for every location on the server?

Best Answer

But this still does not do the trick, there is still the same css content missing

Apache processes ProxyPass directives in the order they are declared, and the first match wins. So put more specific matches first

ProxyPass /something http://10.208.202.2:8762/something/
ProxyPassReverse /something http://10.208.202.2:8762/something/
ProxyPass / http://10.208.202.2:8762/abc/
ProxyPassReverse / http://10.208.202.2:8762/abc/

is the necessary order otherwise the /something is never matched.

Any suggestions what can I do, to make this work without adding proxypass entry for every location on the server?

Basically, if you want a different file structure to be served, than is present on the proxied location, then generally you are going to have to write a ProxyPass for every exception to the default.

If what you are trying to achieve is to make http://10.208.202.2:8762/abc/index.html the default page on your website, you might be better to do that with a redirect, otherwise it will mess up your page relative links. Something like this should work;

RedirectMatch ^/$ /abc/
Related Topic