Copyright © 2010 Frank's Blog.
Reverse Proxy Server
Written by: Frank Mancuso
Website: http://frankmancuso
In this document, I will show you how to use Apache 2 to server as a front end to different internal web server. You will be able to serve over one internet IP address a bunch of back bone web servers.
Compiling Apache2
http://httpd.apache.org/ ( download the latest version of Apache 2 )
In this document, I will use version 2.0.59.
|
mkdir /usr/local/www mkdir /usr/local/www/src cd /usr/local/www/src wget http://apache.oregonstate.edu/httpd/httpd-2.0.59.tar.gz tar –xzvf httpd-2.0.59.tar.gz cd httpd-2.0.59 ./configure –prefix=/usr/local/www/proxy \ –disable-include –disable-status –disable-autoindex \ make make install groupadd proxy |
Putting it into action
This is a sample of my httpd.conf file.
|
## Proxy Server Config ServerRoot “/usr/local/www/proxy” MaxKeepAliveRequests 100 User proxy ServerAdmin root@localhost UseCanonicalName Off DocumentRoot “/usr/local/www/proxy/htdocs” <Directory /> </Directory> <Directory “/usr/local/www/proxy/htdocs”> </Directory> DirectoryIndex index.html <FilesMatch “^\.ht”> </FilesMatch> TypesConfig conf/mime.types DefaultType text/plain <IfModule mod_mime_magic.c> HostnameLookups Off ErrorLog logs/error_log LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined LogFormat “%{Referer}i -> %U” referer CustomLog logs/access_log common ServerTokens Prod ServerSignature Off
NameVirtualHost 10.0.0.1 # Note: replace 10.0.0.1 with your external ip address
# This first virtual host, I will forward http requests to a server running on the local class #A ip address. <VirtualHost 10.0.0.1> ServerName example.local ProxyPass / http://10.0.0.3/example/ </VirtualHost>
# This example, I can use a sub directory on a different host Let says I just wanted to host # a directory on my main web site that was written in ASP or JSP, so I would forward it a # internet web server.
<VirtualHost 10.0.0.1> ServerName example.local ProxyPass /pdf http://10.0.0.4/pdf/ </VirtualHost>
# Now when someone visited http://example.local/pdf/ it would be reversed to #10.0.0.4/pdf/ |
After playing around in your test lab, you should get an idea how easy Apache 2 can be used as a reverse proxy server.
