23

I've got 2 apache servers set up. One on port 80 and another on port 8077. I'm wanting to see everything on the server on 8077 via a reverse proxy. At the moment I've got:

ProxyPreserveHost Off
ProxyHTMLInterp On
ProxyPass /translate/ http://www.example.com:8077/
ProxyPassReverse /translate/ http://www.example.com:8077/
ProxyHTMLURLMap / /translate/

This allows me to get to the initial page of the site, but the links to images, css and other pages don't work.

For example the css in the html shows as

/css/style.css

where I actually want it to be

/translate/css/style.css

For it to pick up the file from the 8077 server. What can I do with the current setting to get that to work?

Nix
  • 57,072
  • 29
  • 149
  • 198
Andrew
  • 7,548
  • 7
  • 50
  • 72

1 Answers1

37

Ok, this is what I ended up doing to get it working

ProxyPass /translate/ http://www.example.com:8077/
ProxyPassReverse /translate/ http://www.example.com:8077/

ProxyHTMLURLMap http://www.example.com:8087 /translate/

<Location /translate/>
   ProxyPassReverse /
   SetOutputFilter  proxy-html
   ProxyHTMLURLMap http://www.example.com:8077 /translate/
   ProxyHTMLURLMap / /translate/
   ProxyHTMLURLMap  /translate/ /translate/
   RequestHeader    unset  Accept-Encoding
</Location>

This seems to work well. The ProxyHTMLURLMap http://www.example.com:8077 /translate/ line was only needed to translate some "referrer" based urls that caused some pages to end up trying to serve directly from the 8077 port server.

Andrew
  • 7,548
  • 7
  • 50
  • 72
  • 1
    Good solution. This approach still does not help me with links inside CSS and JS though.. they don't get proxied. – LauriK Sep 23 '16 at 12:27
  • is this file the conf file? – corlaez Mar 21 '17 at 20:26
  • This worked for me ONLY in concert with https://stackoverflow.com/questions/32340737/setting-up-mod-proxy-html-on-centos-7 because I'm running CentOS7 and I needed to ```sudo yum install mod_proxy_html``` in the first place – blahblahetcetc Jul 19 '19 at 21:33
  • @LauriK have you found any solution for proxying links inside CSS and JS? I have the same problem. None of the solutions I found so far address that ... From the Apache docs it seems that `ProxyHTMLExtended` is the one to use https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html#proxyhtmlextended – Normadize Mar 03 '20 at 13:31
  • Ooohboy, this is an old one. If I recall correctly then my problem was actually somewhere else. Sorry – LauriK Mar 04 '20 at 21:21