Windows – HTTP load balancer with header-based routing

httphttp-headersload balancingPROXYwindows

I am looking for a HTTP load balancing solution that will provide the following:

1) Accept HTTP connections on port X and forward them to one of multiple other hosts (and/or ports), either randomly or in a round-robin manner.

2) If the server reply contains a certain HTTP header with a certain value (i.e. 'Magic-Number: 12345'), remember it and forward all following requests containing the same header to this server.

3) At certain intervals, perform a keep-alive test by sending a specified HTTP request to all destination servers. If either server does not reply, stop forwarding to it until it comes online again.

4) (Not crucial, but nice to have) Accept HTTPS connections from clients and translate them to HTTP connections to the servers.

The solution must consist of free and/or open source software and run under Windows 200x Server.

Any suggestions?

Update: Cygwin or Portable Ubuntu (or other Colinux distribution) are also viable options, if they are able to run the appropriate *nix solutions.

Best Answer

I'm writting this out of my head/memory as I don't have anything at hand to verify whether it works correctly or not, but I hope this might be some hint for you.

So, my answer is:

Of course you can do this with Apache's mod_proxy_balancer. You should be able to acomplish this with something like that:

ProxyPassReverse / http://host1:80/
ProxyPassReverse / http://host2:80/

<Proxy balancer://cluster>
  BalancerMember http://host1:80 route=LB1
  BalancerMember http://host2:80 route=LB2
  ProxySet stickysession=MYSESSIONID
</Proxy>

So, regarding point 1, read mod_proxy_balancer's "Request Counting Algorithm" section.

Regarding point 2: I really don't know about HTTP header parsing. Above example uses additional URL parameter MYSESSIONID to proxy traffic being part of the same connection to the same host. I guess you can also use cookies. Eitherway this should be handled by application identied as LB1 or LB2 (these are added as part of session id or cookie).

Re 3: load balancer monitors all it's members and disables them when they're unresponsive. You can also enable/disable nodes through web interface (mod_status, see "Enabling Balancer Manager Support").

As for the point 4, you can setup SSL enabled VirtualHost listening on port 443 that proxies all the trafic to balancer members port 80.