Multiple Apache Servers on one IP over port 80

As we’re now running a virtual server we decided to take advantage of this and create a second server which could store less critical data, such as additional websites which we occasionally host for friends or local businesses. However it took some investigation and some intense goggling until we found out about Apache’s Reverse Proxy (mod_proxy) mod.

To configure APache edit your httpd.conf file and uncomment the following line (remove the #)

LoadModule proxy_module modules/mod_proxy.so

Then open up your vHost’s file for our installation it’s located in C:\xampp\apache\conf\extra\httpd-vhosts.conf.

Add the following to the end of your vHosts file.

<VirtualHost *>
ServerName domain.com (the hostname that you would like to setup, make sure it’s configured in your hosts file or DNS)
ServerAlias www.domain.com
ErrorLog “logs/domain.com.log”
ProxyPreserveHost On

<proxy>
Order deny,allow
Allow from all
</proxy>
ProxyPass / http://www.domain.com/
ProxyPassReverse / http://www.domain.com/
</VirtualHost>

Make sure you don’t forget the trailing forward slash in the ProxyPass area otherwise you’ll have problems with referring to directories on the second Apache installation.

The next step is to configure the vHosts file on your second Apache installation to know what to do with the ServerName/ServerAlias.

Which is as simple as adding the following to the vHost’s file on the second Apache server.

<VirtualHost *:80>
    DocumentRoot “C:/xampp/htdocs/domain.com”
    ServerName domain.com
   ServerAlias www.domain.com
   
  <Directory “C:/xampp/htdocs/domain.com”>
    Order allow,deny
    Allow from all
  </Directory>

</VirtualHost>

That should be all the setup that’s required, you will need to change the Document locations for your sites however we’ve provided you with a good skeleton to know what you should have at a minimum. Note we also use the XAMPP for Windows.