2

I have a question about forwarding of the hostheader inside a network.

My setup is this: - On the front I have a Linksys router - Behind the router I have 3-4 test webservers with different setups - I'm in a windows environment

What I want do do, is having af sub-domain/CNAME following through the router to the different servers. Eg. I have "website1.domain.com" and "website2.domain.com" and I want website1 to forward to my testwebserver 1 and website2 to forward to my testwebserver 2.

In my current setup I can do it in the router, but I only handles ports, so the result is that all traffic on port 80, have to go to one server. This is a problem because then I can only exhibit one webserver at a time.

I would like if I could install some software on a windows-server that all traffic go thruogh so It's easy to setup new forwards.

Anybody have any input?

Regards Thomas

Thomas
  • 181
  • 1
  • 1
  • 5

3 Answers3

1

There is a third-party software for Windows (IIS), which - besides other things - does this job pretty well: ISAPI Rewrite.

ISAPI Rewrite is a powerful URL manipulation engine based on regular expressions. It acts mostly like Apache's mod_Rewrite, but is designed specifically for Microsoft's Internet Information Server (IIS). ISAPI Rewrite is an ISAPI filter written in pure C/C++ so it is extremely fast. ISAPI_Rewrite gives you the freedom to go beyond the standard URL schemes and develop your own scheme.

I used it for different purposes on our servers and it worked very well. Search for "Proxying". Here is the documentation for the RewriteProxy Rule.

Edit:

You could use these rules

RewriteCond %{HTTP_HOST} ^mydomain.com$ 
RewriteProxy ^(.*) http://local-server-ip/appdir-for-domain/$1 [H,A,L]

RewriteCond %{HTTP_HOST} ^myotherdomain.com$ 
RewriteProxy ^(.*) http://local-server-ip/appdir-for-otherdomain/$1 [H,A,L]

or something like this:

RewriteCond %{HTTP_HOST} ^mydomain.com$ 
RewriteProxy ^(.*) http://mydomain.com.intranet$1 [H,A,L]

RewriteCond %{HTTP_HOST} ^myotherdomain.com$ 
RewriteProxy ^(.*) http://myotherdomain.com.intranet$1 [H,A,L]
splattne
  • 28,348
  • 19
  • 97
  • 147
  • Hi I have installed ISAPI Rewrite now, but must confess that the rewriting part looks a bit complex. Say I want the hostheader "website1.domain.com" to forward to an IP: 192.168.1.20. What do I have to write in my htaccess file? I'm no regEx expert atall - so hope you could help. – Thomas Jun 11 '09 at 08:43
  • One solution could be this (in the httpd.ini file): RewriteCond %{HTTP_HOST} ^mydomain.com$ RewriteProxy ^(.*) http: // local-server-ip/appdir-for-domain/$1 [H,A,L] I know, this means you'll have one web with a lot of apps... I'm trying to find a better solution. You could give internal pseudo headers and set the local DNS to the server, like 'www.mydomain.com.intranet' and prxying to that internal name... – splattne Jun 11 '09 at 09:00
  • Hmm, I tried to copy the line you wrote but got back an error. I'm to green with the RegEx to configure the tool :-( Wish I could just maintain a list of "domain-strings" pointing to an internal IP-adress. Kind of like when you edit your Hosts-file, but just to forwarding traffic on port 80. – Thomas Jun 11 '09 at 11:56
0

Throw apache on there, use mod_proxy to forward to wherever and whatever you like.

womble
  • 95,029
  • 29
  • 173
  • 228
0

If you want to stick with MS stuff then ISA Server can do this. It's an expensive solution, though you can sometimes find ISA on ebay for reasonable prices. Avoid ISA 2000, which is pants, and use either ISA 2004 or ISA 2006.

Alternatively any reverse proxy can do this. A cheap and reliable solution would be SQUID, though the config can seem unnecessarily tortuous to us Windows chaps. I've used SQUID and it works very well.

JR

John Rennie
  • 7,756
  • 1
  • 22
  • 34
  • I like the thought of staying on the Windows platform a lot. Downloaded SQUID and unpacked. Looks like it is kind of complex to install and configure? Do I just set it up as default website in my IIS? – Thomas Jun 11 '09 at 11:58
  • SQUID listens on port 3128, so you'd need to configure inbound port 80 on your router to redirect to port 3128. Then you fiddle with the bloody complicated SQUID config file to configure the reverse relay. If you Google for "squid reverse proxy" or something similar you should find a howto. – John Rennie Jun 11 '09 at 17:15