Internet Information Services 5.x and 6.0
Internet Information Services (IIS) 5.x and 6.0 have no built-in tools to do load balancing. However, third party tools do exist.
One third-party tool is ISAPI_Rewrite, which aims to enable Apache mod_rewrite on IIS.
Sessionless requests
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.66
RewriteEngine on
RewriteMap servers rnd:hosts.txt
RewriteRule ^/(.*) http://${servers:host}/$1 [P,L] - These configuration entries can be put at the server level in the httpd.conf file.
- The
RewriteMapinstruction uses a round-robin algorithm to select a host based on the content of the hosts.txt file, which has following content:host GAS1.corporate.com|GAS2.corporate.com - The
RewriteRuleinstruction replaces the server host of incoming requests by the content of theservers:hostvariable, then forwards the request to the chosen machine.
For example, the http://localhost/ws/r/echo URL
will be rewritten to http://GAS1.corporate.com/ws/r/echo,
assuming that the GAS1.corporate.com server has been chosen.
Session-bound requests
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.66
RewriteEngine on
RewriteMap servers rnd:vdirs.txt
RewriteRule ^/gas/(.*) /${servers:vdir}/$1
RewriteRule ^/GAS1/(.*) http://GAS1.corporate.com/GAS1/$1 [P,L]
RewriteRule ^/GAS2/(.*) http://GAS2.corporate.com/GAS2/$1 [P,L]- These configuration entries can be put at the server level in the httpd.conf file.
- The
RewriteMapinstruction uses a round-robin algorithm to set the value of theservers:vdirvariable based on the content of the vdirs.txt file, which has following content:vdir GAS1|GAS2 - For starting-session requests, the
RewriteRuleinstruction replaces thegaspart of the URL by the content of theservers:vdirvariable, which is eitherGAS1orGAS2; then other rewrite rules will be applied to set the host. For session-bound requests, the rule will not match so the rule doesn't apply. - The host name of requests who's URL begin with
/GAS1/will be set to GAS1.corporate.com. - The host name of requests who's URL begin with
/GAS2/will be set to GAS2.corporate.com.
For example, the http://localhost/gas/ua/r/gwc-demo URL will be rewritten to
http://localhost/GAS2/ua/r/gwc-demo, assuming that the
servers:vdir variable contains GAS2 at this time, then
will be rewritten to http://GAS2.corporate.com/GAS2/wa/r/gwc-demo.
Likewise, the http://localhost/GAS2/wa/sua/93837374/1 URL will be rewritten
to http://GAS2.corporate.com/GAS2/wa/sua/93837374/1.