Forum Discussion
Rikidosan_77458
Nimbostratus
Jul 01, 2009Disable persistence for only certain server
Hi,
I have the following rule that uses different persistence based on what kind of user connects to the virtual server. For example, when a mobile device connects, persistence is based on a session ID, and when another web client connects, a random value (based on IP and TCP port number) is used to create a cookie and that value is used for persistence. The rule works fine as it is, but I would like to add functionality to disable persistence for when a server in the pool with a low priority has been selected(a sorry server for example). Without that, users that have once been directed to that server will keep being directed to that server, even when the real servers are back up again.
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/mobile/") } {
set sid [findstr [string tolower [HTTP::uri]] "sid=" 4 ";"]
set need_cookie 0
if { $sid != "" } {
persist uie $sid 1800
}
}
else {
if { [HTTP::cookie exists bigip_persist] } {
log local0. " [HTTP::cookie exists bigip_persist] "
set need_cookie 0
log local0. "no need for cookie cause value is $need_cookie"
set cookie_id [HTTP::cookie value bigip_persist]
if { $cookie_id != "" } {
persist uie $cookie_id 1800
}
}
else { set need_cookie 1 }
}
}
when HTTP_RESPONSE {
if { ($need_cookie == 1) } {
} {
HTTP::cookie insert name "bigip_persist" value [IP::client_addr][TCP::remote_port]
}
}
I have tried adding the code below to the rule above the HTTP_RESPONSE event, but this doesn't achieve what I described above becasue it keeps persisting. Any ideas what is wrong here, or if there is another way to achieve this? (in below example the sorry server that I don't want to persist on is "1.2.3.4"
when SERVER_CONNECTED {
log local0. "Node IP address: [IP::server_addr]"
if { [IP::server_addr] equals "1.2.3.4" } {
persist none
}
}
- The_Bhattman
Nimbostratus
Have you tried using the event "when LB_SELECTED". It's triggered when the system selects a pool member. This is probably where you can determine to negate persistence. - Guido_Vosmeer_9Historic F5 AccountI have tried a similar thing in the past but disabling persistence based on the real server IP didn't work because when this event (LB_SELECTED) takes place there is no server side connection established yet
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