Forum Discussion
Yung_Liu_113940
Nimbostratus
Feb 01, 2006How 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
}
}
10 Replies
- unRuleY_95363Historic F5 AccountDo you have a cookie persist profile on the virtual server?
It would probably be best to have the cookie persist profile on the virtual server (if you don't already), and then change your rule slightly. You shouldn't need the "persist cookie insert cookiemonster" line that you currently have at all. Instead you'll want to add "persist none" in the else part of your if:... HTTP::uri "/$newuri" Remove this persist command since it is already defined on the virtual pool testpool member $myserverip 80 } else { pool testpool persist none } } - Yung_Liu_113940
Nimbostratus
Thank you for your reply. Although I have cookie persistence profile (insert mode) defined on the virtual server, I don't see BigIP sending Cookie to the client if URL contains ip=x.x.x.x. Is this an expected behavior?
Thank you, - Colin_Walker_12Historic F5 AccountDid you modify your rule as unruley suggested above? If you have the cookie insert profile associated with the virtual, you don't want to set persistence in your rule, or you'll likely stop the profile from doing its job.
-Colin - Yung_Liu_113940
Nimbostratus
Colin,
I followed unRuley's instruction and modified the iRule (please see below) but I still don't see BigIP sending cookie when URI contain's ip=x.x.x.x. I tried this on both version 9.0 and 9.2 without much success. Any help on this is greatly appreciated.
Thanks,
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"
pool testpool member $myserverip 80
}
else {
pool testpool
persist none
}
} - unRuleY_95363Historic F5 AccountHow are you not seeing the Cookie? Are you watching a network trace of the HTTP response going to the client.
It's very difficult for us to debug your setup via this forum. You may want to contact support as they will be able to further scrutinize your setup and configuration. - Yung_Liu_113940
Nimbostratus
I am using a software called IEWatch which is a IE plugin that does HTTP traffic analysis. As for contacting F5 technical support, I tried both web support and phone support and in both cases I was told to get help from DevCentral even though we have support contract with F5.
Yung - Colin_Walker_12Historic F5 AccountYung,
If you remove the "persist none" statement from the else clause in your rule, are you seeing the cookie being inserted as expected?
I'm trying to determine whether the issue has to do with the specific coding of the rule, or the cookie insert in general.
Thanks,
-Colin - Yung_Liu_113940
Nimbostratus
Colin,
I removed persist none and it did not help. This problem is easily reproducible. I was able to reproduce this on 2 different F5 3400 load balancers with one running 9.0 and the other running 9.2. Can someone at F5 test this on a load balancer running BigIP 9.2? Could this be a bug?
Thank you,
Yung - unRuleY_95363Historic F5 AccountPlease contact support as this does sound like a bug.
- Don't you need to be setting persistence when HTTP_RESPONSE event happens? If your server does not send back that cookie, you will not see it coming back to the client.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects