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.

Lets say I have 3 URLs and they all point to the same reverse proxy. I would like to have the requests being forwarded to the web servers behind the proxy based on the host header:

webfront1.example.com > reverseproxy.example.com > backend1.example.com
webfront2.example.com > reverseproxy.example.com > backend2.example.com
webfront3.example.com > reverseproxy.example.com > backend3.example.com

Based on what I have read, I can configure reverseproxy.example.com/webfront1 > backend1.example.com, reverseproxy.example.com/webfront2 > backend2.example.com, etc.

I am wondering if proxy based on host header is even possible or if I used the wrong approach entirely.

share|improve this question
    
I am not entirely sure I understand your desired setup. Are webfront1.example.com, reverseproxy.example.com and backend1.example.com 3 different servers/machines? –  brain99 Aug 29 '12 at 19:27
    
sorry, i should have made it more clear... webfront1.example.com would be a cname in dns that points to reverseproxy.example.com and backend1.example.com is a different server. –  zigzagip Aug 29 '12 at 19:31

1 Answer 1

You can use name based virtualhosts for that. Example config:

NameVirtualHost *:80
ProxyRequests off

<VirtualHost *:80>
  ServerName webfront1.example.com
  ProxyPass / http://backend1.example.com/
  ProxyPassReverse / http://backend1.example.com/
</VirtualHost>
<VirtualHost *:80>
  ServerName webfront2.example.com
  ProxyPass / http://backend2.example.com/
  ProxyPassReverse / http://backend2.example.com/
</VirtualHost>

Note that if you want to use SSL on reverseproxy.example.com, things become more complicated.

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.