Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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