One of the big things I wanted to be able to do was to host my own websites etc from my test gear. This will allow me to run different configurations and be able to optimize some websites in terms of automatic setup etc. There was only one problem, I am on a home ADSL connection with a single static IP.

I was sure there would be a way around this issue so I started to look up load balances and how to implement them figuring that I would be able to redirect particular sites based on the HTTP header information. (I also considered SQUID reverse proxy as an option) After looking into it I found that Apache would also be able to proxy these connections. I figured I would use Apache as I thought the setup would be a little easier (Plus I am going to be configuring Apache in the future so the head start would help).

I found a great guide which I have used to get started here. This site will have a few changes to what has been done there.

First things first the Proxy features need to be enabled in Apache and Apache restarted.

sudo ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled
sudo ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled
sudo /etc/init.d/apache2 restart

Then I created a proxiedhosts virtual hosts file for Apache.

sudo vi /etc/apache2/sites-available/proxiedhosts

I have three types of website that I want to re-direct which are

  1. Cacti, MythTV and Owncloud – This was from an existing server that was already running. I dont want to loose access to this so I need to re-direct that.
  2. My Book it traffic to one server.
  3. All other website traffic to a EHCP server which will handle any other websites I want to host.

So I added the following to the proxiedhosts file.

<VirtualHost *:80>

ServerAlias *
ServerAlias *

    ProxyPreserveHost On
    ProxyRequests off
    ProxyPass /
    ProxyPassReverse /


This code is repeated three times to cover My Book It, with the third redirecting everything else to the other web server.

Once that file is done I linked the file into the sites-enabled folder and restarted apache.

sudo ln -s /etc/apache2/sites-available/proxiedhosts /etc/apache2/sites-enabled
sudo /etc/init.d/apache2 restart

I also disabled the default site as it should not be serving anything

 sudo a2dissite 000-default

And there you have it. The gateway proxy is automatically redirecting visitors to the appropriate website based upon the header value.