The mod_proxy module implements a proxy/gateway for Apache. It implements proxying capability for several different protocols and are divided into additional modules: mod_proxy_http, mod_proxy_ftp, mod_proxy_ajp, mod_proxy_balancer, and mod_proxy_connect.
Apache can be configured in both a forward and reverse proxy mode. Only reverse proxy will be discussed in this section.
A reverse proxy is a gateway for servers, and enables one web server to provide content from another transparently.
Note: A reverse proxy is activated using the ProxyPass directive. It is not necessary to turn ProxyRequests on in order to configure a reverse proxy.
Setting Up Reverse Proxy
Enable the mod_proxy module
$ a2enmod proxy
Enable the mod_proxy_http module if you are going to proxy to a http protocol
$ a2enmod proxy_http
Add the following to the /etc/apache2/httpd.conf or a virtual host site in /etc/apache2/sites-available:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost on ProxyPass /foo http://foo.example.com/bar ProxyPassReverse /foo http://foo.example.com/bar
For more information on mod_proxy refer to the Apache documentation at http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Related posts: