Apache's ReverseProxy on Ubuntu

Last modified
Sunday, February 12, 2017 - 07:38

Sometimes you may find the need to shutdown a site for any reason an a specific server, basically the server that is listening to the web, so of course you will always want to keep that site(s) up and running while you perform whatever is needed on it, let's call it, 'external server', on a different environment, 'internal server'.
To do so you need to use an apache module called mod_proxy which enables a web server act as a router of traffic to another server, a tunnel.

- Enable mod_proxy and mod_proxy_http mod_proxy_html on external server
- create a virtual host on internal server pointing to internal server, ex:

<VirtualHost *:80>
    ServerName proxy.example.net
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all

    ProxyPass / http://proxy.example.net/
    ProxyPassReverse / http://proxy.example.net/
    ProxyHTMLURLMap http://proxy.example.net /app1
    <Location />
        Order allow,deny
        Allow from all
        ProxyPassReverse /
#On the above link version 3.0.1 of libapache2-mod-proxy-html
#does not use ProxyHTMLEnable instead uses ProxyHTMLInterp On|Off
#so this problem is coming.
#Ubuntu 10.04 by default uses
#libapache2-mod-proxy-html of version 3.0.1
#Changed the ProxyHTMLEnable to
        ProxyHTMLInterp On
        ProxyHTMLURLMap  /      /app1/
        RequestHeader    unset  Accept-Encoding

modify hosts file on you internal server and add the proper entry:

XXX.XXX.XXX.XXX          proxy.example.net

and finally on internal server you will have a normal virtual host for local.external.server.com

<VirtualHost *:80>
   DocumentRoot /var/www/proxy/www
   ServerName proxy.example.net
   <Directory /var/www/proxy/www>
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.