I have 2 computers behind a router, and a raspberry pi. I have port forwarded port 80 to the public IP, and I want to do the following.

I will describe the end result I'm trying to achieve:

I want traffic sent to


To be received at

And all traffic sent to


To be received at

Currently, I'm running an apache web server with some rewrite rules and a glype proxy to load the local IPs via the Pi, but I am wondering if there is a better way to do it.

  • This is a networking or web servers question, not specific to the raspberry pi. Oct 20, 2013 at 14:00

2 Answers 2


You could probably do this with a load balancer. I wrote an article about setting one up here: http://raspberrywebserver.com/raspberrypicluster/raspberry-pi-cluster.html.

In /etc/apache2/sites-available/default, I set up one cluster with several IP addresses. You would need to set up two clusters, one for IP address and another cluster for (It's not a problem if there's only one node in each cluster).

Then in the same file, you need to add some lines of code to pass traffic to each cluster. Something like this:

ProxyPass http://public_ip/a/* balancer://clustera/
ProxyPass http://public_ip/b/* balancer://clusterb/

You can do this with Apache Rewrite Module. By default Apache comes with rewrite module installed, if don't please do this.

sudo echo "LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so" > /etc/apache2/mods-available/rewrite.load
sudo a2enmod rewrite  
sudo /etc/init.d/apache2 reload

Then you should create a .htaccess file in your web folder (default /var/www/ for debian systems). Add this line into .htaccess file:

RedirectMatch 301 ^/a/(.*)$$  
RedirectMatch 301 ^/b/(.*)$$

If you forward port 80 to server which running apache everything should work fine.

  • I want it accessible from all IPs, not just local ones. Sep 14, 2013 at 12:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.