Technology weblog

Friday Dec 22, 2006

Reverse proxy with Apache

Suppose we have a service running on a server, which is known as to the outside world. To the intranet, this server may be available under a different name (as a matter of fact, in my configuration at home it actually does), but for the moment let's assume that the URL of the service running on the local serer is available at:


and we want to make it available on the Internet via

First of all, Apache must be configured to act as a reverse proxy. To this extent, locate your httpd.conf (on Gentoo Linux, this config file resides in the /etc/apache2 directory). Make sure  mod proxy is enabled by asserting that the following line has been uncommented:

LoadModule proxy_module    modules/
Add the following snippet to your httpd.conf and modify it according to your own specific service settings
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPass /service
Finally, you'll most probably need URL rewriting too, as URLs in your HTML documents need to be converted as well. To this extent, navigate to your modules.d direcotry (in my case in the /etc/apache2/ dir) and look for a file xy_mod_proxy_html.conf, where in my case xy equals 27. Make sure it is enabled by asserting that the following two lines are present and uncommented:
LoadFile    /usr/lib/
LoadModule proxy_html_module    modules/
Add the following snippet, modified for your local set-up as needed
<IfModule mod_proxy_html.c>
ProxyHTMLLogVerbose On
SetOutputFilter proxy-html
That should be all that's needed. If you have any remarks, please leave a comment!


Post a Comment:
Comments are closed for this entry.

Hire us