Reverse Proxy and IIS
I am trying to do something that should be rather simple, but still I can't make it work.
Let's say I have 2 virtual machines on my lan. Those machines are web servers for customer-testing purposes. The old one runs IIS6 and the new one runs IIS7.5
Let's say that I have only one public IP address to use. In the original scenario the public IP was mapped to the old machine, and all was fine.
Now I have the need to "split" this public address between those two machines. What I want to do is, based on the host header, "redirect" or "rewrite" the request to the correct machine.
So far I tried to use the "new" machine with IIS7 as a reverse proxy too, fiddling with ARR and Url Rewrite. I also tried the "Web Farm Framework" in combination with the previous two modules.
Short story: I can't make it work: all the requests are redirected to the "old" machine no matter what.
Long story: I tried to make things as clean as possible. My cleanest attempt was making 2 server farms, the first with the new machine (which is itself) and the second with the old machine.
In my rewrite rules, I put as first rule that anything that matches www1.*.mydomain.com should be routed to webfarm new, and stop processing.
The second rule (which should be checked only if the first one fails) says that anything that matches *.mydomain.com gets routed to webfarm old.
In this scenario, everything gets routed to the old machine. But if I disable the *.mydomain.com rule, the first one actually works. It's like the second rule takes priority if enabled, even if it's under the other one.
If anyone has a solution to this, even a total different approach, you're welcome. I need to split that public IP on those two machines based on host header.
Thanks.
Solution 1:
What you are wanting to do is referred to as a "reverse proxy" and there are many options. Most "load balancers" are reverse proxies with a few niceties.
Your options are pretty much as follows.
-
Setup a new server (Such as NginX or HAProxy)
NginX has the advantage of being a fairly straight forward setup, with some flexibility that is less well documented and harder to configure than IIS/ARR or HAProxy
HAProxy is probably the most robust solution I am listing, but also has the most configuration options
-
Setup Application Request Routing (ARR) and the URL Rewrite modules for IIS on the new server, and have each site with an ARR rule pointing to the internal site/server.
You will need to have a host entry, or separate IP binding for each site on the internal server.
You will need to have each site setup on the public server, or a complex ARR rule. I find that having each site with its' own "site" in IIS tends to be straight forward.
The gotchas in such a situation are as follows.
Your public proxy/iis instance will return an error html when it can't reach the internal server for whatever reason. (If you have say xml, or json services on the older server, you may want to migrate).
ARR on Server 2008, and 2008 R2 do not support forwarding WebSocket requests. I am unsure of 2012.
I know this is an older question, but wanted to do a more complete answer.