FruitNotes beta
Your All-in-One Online Notebook
FruitNotes Blogs | Home  
Creating a cookie affinity load balancer with Apache mod_proxy and IIS
Last updated at (Mon Mar 16 2009 18:33:07)
Posted by: Nitin Gupta
0%




Reference: http://macacochefe.blogspot.com/2007/08/iis-creating-cookie-affinity-load.html

 

Segunda-feira, Agosto 13, 2007

IIS: Creating a cookie affinity load balancer with Apache mod_proxy and IIS

 


by Rodrigo Sol and Sérgio Junqueira


Apache’s mod_proxy and mod_proxy_balancer are a good choice to create a load balancer for your web application. When we needed to configure it for our IIS ASP 3.0 application we did not find any document to help us. There are many tutorials that explain how to accomplish it using JBoss or Tomcat as back end servers, but not for Microsoft IIS.

In our architecture we use one server running Apache as load balancer and three back end servers running the IIS application.

Remember: Using only one server for load balancing means that you have a single point of failure in your system. Another Apache server will be added soon to avoid this problem.

Configuration for the Apache Load Balancer Server:

1 – Download Apache 2.3

2 – Turn on the following modules in httpd.conf:

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

LoadModule proxy_connect_module modules/mod_proxy_connect.so

LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule proxy_ftp_module modules/mod_proxy_ftp.so


3 – Configure the load balancer in httpd.conf:

Order deny,allow
Allow from all

ProxyPreserveHost On
ProxyPass / balancer://mycluster/ lbmethod=byrequests stickysession=BALANCEID nofailover=ON
ProxyPassReverse / balancer://mycluster/

BalancerMember http://your-server-node1/ route=node1
BalancerMember http://your-server-node2/ route=node2

4 – Save httpd.conf and start Apache. Tip: Enable debug log mode to see relevant log events about mod_porxy_balancer.

Configuration for each IIS Application node:

1 – Open IIS Administration Console

2 – Open your website or virtual directory properties

3 – Choose HTTP Header tab

4 – Click into ADD button

5 – Type “Set-Cookie” in the Custom Header Name.

6 – Type “BALANCEID=mycluster.node1; path=/;” in the Custom Header Value

7 – Click OK. Repeat these steps for each node in your cluster. Don’t forget to change the custom header value to the corresponding node id. For node2 use “mycluster.node2”.

There is an important undocumented point. In order put cookie affinity to work it is necessary to use a dot before the node id suffix in the cookie value. If you try to create the cookie inside the ASP application using the Response.Cookie method, URLEncode will be automatically called. This will change all dots in the cookie value into the “.” string and will cause cookie affinity to fail. This problem does not happen in ASP.net.

1 Comments:

At 5:07 PM, Anonymous Anônimo said...

Thank you for this excellent (and timely) entry. I am just learning about how to get Apache2 to proxy for IIS. This confirms that it is possible and also gives me some ideas in terms of load-balancing.

 

Postar um comentário

<< Home

 


Rate this blog

   Report Abuse


Comments


Leave your comment(s) below:
To start Your own Blog




Other Blogs
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
2007 FruitNotes.com - All Rights Reserved.