How do I redirect to different backend server based on URL using Apache?

0
(0)

2

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

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

<VirtualHost *:80>
   ServerName def.mydomain.com
   ProxyPass / http://192.168.0.10
   ProxyPassReverse / http://192.168.0.10
</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.

840

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Scroll to Top