Apache 2.2 reverse proxy not working

user190780 picture user190780 · Oct 15, 2009 · Viewed 15k times · Source

I am trying to set up my apache (version 2.2.3) to work as reverse proxy. I configured apache on public server as it is described at http://www.askapache.com/htaccess/reverse-proxy-apache.html

LoadModule proxy_module      modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule headers_module    modules/mod_headers.so
LoadFile   /usr/lib/libxml2.so
LoadModule proxy_html_module modules/mod_proxy_html.so

ProxyRequests off
ProxyPass /app1/ http://internal1.example.com/page1/
ProxyPassReverse /app1/ http://internal1.example.com/page1/
ProxyHTMLURLMap http://internal1.example.com/page1/ /app1/


internal1 is other server in local network.

Home page (www.example.com/app1/) is displayed correctly, but the problem occures when my internal server does redirection. In this case my browser (Firefox 3.5.3 or Internet Explorer 7) searches for address in local network (internal1.example.com/page1/). It seems for me that ProxyPassReverse directive is ignored by apache.

Answer

Rizvi Iqubal picture Rizvi Iqubal · Jun 18, 2012

Just before ProxyPass add this parameter ProxyPreserveHost On

This will preserve host. (http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost)