View Full Version : Redirect by host header
jamesngm
2006-05-10, 07:11 PM CDT
I am trying to figure out how I can receive multiple requests to the same ip address and redirect to different servers based off the host_header... Let me give you an example of what I am trying to do:
host to IP:
host1.routeme.com --> 71.35.254.123 (WAN IP)
host2.routeme.com --> 71.35.254.123 (WAN IP)
If host_header = host1.routeme.com redirect to local ip 192.168.0.21 (LAN IP)
If host_header = host2.routeme.com redirect to local ip 192.168.0.22 (LAN IP)
I was thinking that I might have to use a proxy but I cant find one that will redirect using a host_header instead of an IP.
Maybe I am thinking about this the wrong way...
Please help! :confused:
Respectfully,
James
Zotter
2006-05-10, 11:17 PM CDT
I could use the same thing - but never found a usable solution.
What I did do though, was setup VirtualHosts on my apache server. Currently hosting 3 different 'web sites' (domains) on my one box.
ccrvic
2006-05-11, 01:06 AM CDT
I am trying to figure out how I can receive multiple requests to the same ip address and redirect to different servers based off the host_header... Let me give you an example of what I am trying to do:
host to IP:
host1.routeme.com --> 71.35.254.123 (WAN IP)
host2.routeme.com --> 71.35.254.123 (WAN IP)
If host_header = host1.routeme.com redirect to local ip 192.168.0.21 (LAN IP)
If host_header = host2.routeme.com redirect to local ip 192.168.0.22 (LAN IP)
Depending on the scope of what you're up to, this *might* be impossible.
Are you trying to run web servers on separate machines behind a NAT router, or are you trying to redirect all types traffic for that hostname? The latter can't be done, you see...
If you're just trying to partition web server load, take a look at Apache's ProxyPass and ProxyPassReverse directives. They should do what you need.
Vic.
jamesngm
2006-05-11, 07:34 AM CDT
ccrvic,
I have my fedora box DMZ to the web. I am using DynDns to route my dynamic IP to the WAN IP. I am able to connect to the fedora box. Now, from here I want fedora to look at the packet being sent, read the host header, and depending on what the host header is, ie: host1.routeme.com or host2.routeme.com. Forward or redirect that packet to a different server on the LAN ie: 192.168.10.1 for host1.routeme.com or 192.168.10.2 for host2.routeme.com...
There has to be a solution... This is deffinitly logically possible... The problem is finding the solution...
Thank you for your assistance. :)
If there is anything you can think of please let me know. This is still a work in progress...
ccrvic
2006-05-11, 07:51 AM CDT
Now, from here I want fedora to look at the packet being sent, read the host header, and depending on what the host header is, ie: host1.routeme.com or host2.routeme.com. Forward or redirect that packet to a different server on the LAN ie: 192.168.10.1 for host1.routeme.com or 192.168.10.2 for host2.routeme.com...
Yes, I understand that. But the way to do it depends on the context in which you are operating.
If you're trying to redirect web traffic, use the ProxyPass and ProxyPassReverse directives I mentioned earlier.
If you're trying to do this for all traffic, then it is impossible. Most IP traffic will not contain any such hostname information. And if it's not there, you can't filter on it.
There has to be a solution... This is deffinitly logically possible... The problem is finding the solution...
The two scenarios are above - one has a solution, one does not.
You need to be a little more specific in terms of the traffic you're interested in to determine whether the solution is trivial or impossible.
Vic.
jamesngm
2006-05-11, 09:48 AM CDT
ccrvic,
I apologize. All I am trying to do is provide 2 seperate web servers, I do not want use IIS host header on one server, I want 2 seperate servers inside the LAN to host web sites. I will take a look at Apach ProxyPass and ProxyPassReverse and see if that will accomplish what I need. Thank you for your support.
ccrvic
2006-05-11, 10:43 AM CDT
All I am trying to do is provide 2 seperate web servers
Right - then you can do it.
I do not want use IIS host header on one server
Where did IIS come into it?
I want 2 seperate servers inside the LAN to host web sites.
That's fine - but think about how you're going to do this.
If you want to interpret HTTP requests, you could try using some sort of L7 packet filter to route packets - but that's going to be tricky, and you'll probably end up writing quite a bit of it.
If you don't do that, you'll have to send port 80 to a single host - one of your web servers. By an extreme co-incidence, a web server just happens to be the best tool to interpret HTTP headers, so all's well there.
So all you need do now is to off-load the work to the other web server when the request is for a particular domain. And that's exactly what the directives I mentioned earlier will do for you.
I will take a look at Apach ProxyPass and ProxyPassReverse and see if that will accomplish what I need.
You'll find it quicker than just asking the same question... :-)
Vic.
jamesngm
2006-05-11, 11:47 AM CDT
Thanks ccrvic,
I will post if I run into any problems.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.