Hi again,
In this blog I will explain how we set apache as a proxy server, this has many advantages and also this gives more security to the server.
Why use apache as proxy?
By using apache as proxy, you can forward then apache queries to a different server/port, so the end user wont know the actual IP address/Port number of the server. The server which the traffics are being passed to need not have an internet connection, but only a private network connection with proxy-apache server.
This method can be used :
1) To prevent DDOS attacks to your web server.
2) To enhance security by hiding the main server from public networks.
How to use apache as proxy server:
On proxy server compile apache with proxy options:
# ./configure –enable-proxy –enable-proxy-ftp –enable-proxy-http –enable-proxy-connect
Note: You can add additional modules along with proxy modules.
I assume you configured apache with proxy modules. Now open the VirtualHost file of your website and add the following lines.
<VirtualHost *:80>
ServerName example.com
ServerAdmin admin@example.com
ProxyPreserveHost On
ProxyPass / http://IP_ADDRESS_OF_WEBSERVER:PORT/
ProxyPassReverse / http://IP_ADDRESS_OF_WEBSERVER:PORT/
DocumentRoot /var/www
</VirtualHost>
Replace IP_ADDRESS_OF_WEBSERVER with IP address of the actual webserver and PORT with the webserver port on IP_ADDRESS_OF_WEBSERVER.
Example:
If the second server has the IP address 192.168.1.0, and webserver (eg: apache, tomcat, jboss etc) is listening on port 8080, the VirtualHost entry becomes:
<VirtualHost *:80>
ServerName example.com
ServerAdmin admin@example.com
ProxyPreserveHost On
ProxyPass / http://192.168.1.0:8080/
ProxyPassReverse / http://192.168.1.0:8080
DocumentRoot /var/www
</VirtualHost>

The same method can be used if you’re running another webserver on port 8080 and want to simply redirect traffic to port 8080. In that case you need to replace 192.168.1.0 with “localhost”. You can use this method for a load-balancing between apache-tomcat or apache-jboss combinations.
That’s all guys! Thanks !
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.