1

I'm a newbie to Apache, sorry if this is a documented solution somewhere. I have been scouring the web and can't seem to find this answer ...

I would like to redirect traffic based on the URL coming into my Debian Wheezy web server running Apapche to different backend servers. For example, if the URL is http://abc.mydomain.com it will be passed on to server IP 192.168.0.100, but if the URL is http://def.mydomain.com it will be passed to server IP 192.168.0.110.

Thanks in advance for any help.

2 Answers 2

2

You can use your Apache frontend Server as a reverse proxy for your backend servers : mod_proxy

e.g :

<VirtualHost *:80>
   ServerName abc.mydomain.com
   ProxyPass / http://192.168.0.100
   ProxyPassReverse / http://192.168.0.100
</VirtualHost>

<VirtualHost *:80>
   ServerName def.mydomain.com
   ProxyPass / http://192.168.0.110
   ProxyPassReverse / http://192.168.0.110
</VirtualHost>

You will have to enable these modules :

a2enmod proxy 
a2enmod proxy_http

The advantage of mod_proxy is that it is transparent for the end-user : the URL in the address bar of their browser will stay unchanged : it will remain http://abc.mydomain.com but in fact they are served by http://192.168.0.100.

2

What you want to do is called Reverse Proxy. Alternatively you can use Nginx which outperforms Apache as a reverse proxy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .