C_D_18583
Apr 22, 2008Nimbostratus
Cookie set by application server
How can I write a rule that can pick up the cookie that is set by the application server and have the ability to reset it.
Essentially the requirement is when a user logins in to the application the first time F5 routes to any node but the applications will set the cookie and that cookie will be persisted by F5.
However , if that node should go down we would like F5 to clear that cookie and go back to reselect another node and then the application will set another cookie.
The rules partially works ( clears the local cookie ( myCookie ) when the node is down ) but the APP_SESSION_COOKIE is not reset hence it continues to persisting to a node that is marked down:
Please advise
when RULE_INIT {
set ::myPool default_pool
set ::myPort 80
set ::myCookie APP_SESSION_COOKIE
}
when HTTP_REQUEST {
set myServer [findclass [substr [HTTP::cookie $::myCookie] 0 2] $::ip_list " "]
log local0. "The Cookie identifier is: [substr [HTTP::cookie $::myCookie] 0 2]"
if { $myServer ne "" } {
if { [LB::status pool $::myPool member $myServer $::myPort] ne "down" } {
pool $::myPool member $myServer $::myPort
log local0. "Server picked is: $myServer $::myPort"
}
else {
HTTP::cookie remove "$::myCookie"
pool $::myPool
log local0. "Selected server [IP::server_addr] is down, reloadbalancing."
}
}
else {
pool $::myPool
log local0. "No valid cookie/server pairing found, load balancing request to any server in $::myPool."
}
}