Apache reverse proxy Filed Under: Apache
Introduction
This tutorial will only explain the configuration of the Apache server as a reverse proxy.
A reverse proxy is normally used to bring several servers into the same URL space. The client normally connects to the reverse proxy as a normal web server. The reverse proxy then with the request of the client decides where to send the request and returns the request to the client as it was itself the original server.
Configuration of the Reverse Proxy
Before start the configuration on the reverse proxy settings, make sure the module mod_proxy is loaded in apache with the following entry.
LoadModule proxy_module modules/libproxy.so
AddModule mod_proxy.c
A typical configuration of a reverse proxy will be as follows:
ProxyRequest off
ProxyPass /site http://another.server/site2/
ProxyPassReverse /site http://another.server/site2/
Now I will explain the meaning of each line of the config:
ProxyRequest off
– With this line we prevent Apache from running as a forward proxy server. This is done for security reasons.
ProxyPass /site http://another.server.com/site2/
– This line will map the remote server in the space of the reverse proxy. So whenever the proxy server receives a request like http://proxy.server.com/site will proxy the request to http://another.server.com/site2.
This line will only proxy the request to the internal server but the response will pass through without a change to the outside world were it will not work. To make it work we need to next directive.
ProxyPassReverse /site http://another.server.com/site2/
– This directive will translate the responses from the internal server to the address of the proxy server so they can be used by the client.
References
Apache mod_proxy documentation
ApacheWeek tutorial on reverse proxies with Apache
- Permalink
- Alberto Diaz
- 29 Dec 2006 7:24 AM
- Comments (0)