Jan 17, 2012

Reverse Proxy in apache

Reverse Proxy Configuration in apache


            A reverse proxy is a gateway for servers, it can be used whenever multiple web servers must be accessible via a single public IP address. The web servers listen on different ports in the same machine, with the same local IP address or, possibly, on different machines and different local IP addresses altogether. The reverse proxy analyses each incoming call and delivers it to the right server within the local area network.

RedHat Enterprise Linux
Apache 2.x

Configure Apache webserver as a reverse proxy server


1)       Install the required rpm

            # yum install httpd

2)       Enable the proxy related modules in the httpd,conf file

            # vi /etc/httpd/conf/httpd.conf

LoadModule  proxy_module      modules/mod_proxy.so
LoadModule  proxy_http_module modules/mod_proxy_http.so

3)       Add the below entries to the http configuration file.

                        # vi /etc/httpd/conf/httpd.conf

            <IfModule mod_proxy.c>

            ProxyRequests Off
            <Proxy *>
            Order deny,allow
            Allow from all

            ProxyPreserveHost On
            ProxyVia On
            SSLProxyEngine on

            ProxyPass /webdav http://ServerIP:8080/webdav 
            ProxyPassReverse /webdav http://ServerIP:8080/webdav

Note: In the above sample all the request comes to /webdav URL redirect to the another tomcat server. For example Apache server IP is and the tomcat server IP is, then the request like will be redirect to

4)       To enable logging for the reverse proxy, add the below lines in the configuration file

            # vi /etc/httpd/conf/httpd.conf

            <IfModule mod_proxy.c>

            CustomLog logs/access_proxy.log combined
            ErrorLog logs/error_proxy.log


5)       Restart the httpd service

                        # /etc/init.d/httpd restart


1 comment:

Anonymous said...

Thanks a lot!
This worked without any issue.