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
}
}