Yung_Liu_113940
Feb 01, 2006Nimbostratus
How to direct HTTP request to a particular pool member and keep the persistence (cookie insert mode)
Hi,
I am trying to use iRule to direct http request to a particular pool member if the URI contains ip=x.x.x.x where x.x.x.x is the ip of a pool member. One of the requirement is to keep the persistence using cookie insert mode. Here is what I have, I crated a virtual server (www.testvip.com), a pool (testpool) that consists of following 3 web servers, a cookie insert mode persistence profile and assigned it to the virtual server and following iRule assigned to the virtual server. The iRule works as far as dircting the HTTP request to the correct pool member but the cookie persistence is not working. For example, if I point my browser to http://www.testvip.com/ip=10.0.0.1/test.html and I get the test.html page from 10.0.0.1 but the HTTP response header does not contain any Cookies. If I point my browser to http://www.testvip.com/test.html (without ip=x.x.x.x), BigIP will load balance, pick a web server and sends the test.html page and the Cookie. Did I miss something in my iRule? Any help on this is greatly appreciated.
Thank you,
---------------------------------------------------------------
Web server A - 10.0.0.1
Web server B - 10.0.0.2
Web server C - 10.0.0.3
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri contains "ip=" } {
set uri_index [split [HTTP::uri] "/"]
set myserver [string trimleft [lindex $uri_index 1] "/"]
set myserverip [lindex [split $myserver "="] 1]
set newuri [join [lrange $uri_index 2 end]]
HTTP::uri "/$newuri"
persist cookie insert cookiemonster
pool testpool member $myserverip 80
}
else {
pool testpool
}
}