Forum Discussion
Hi!
Making this a reply as the syntax for comments is horrible.
I tried the rule and it seems to do what you want it to do at first glance.
I am curious though about what would happen to the persistent connections if you'd implement this rule. The detach command would close the connection with the server, but the client would be unknowing.
Unless you're using SNAT today letting the load balancer handle the server connection for the client, I imagine this would result in the client sending a request over an open TCP connection ending up at a new server on which the connection is not established. My guess is that this would result in an TCP connection reset forcing the client to open a new session. Could be worth investigating.
A humble suggestion as to the rule syntax would be to replace the switch -glob with a data group list instead:
when HTTP_REQUEST {
set lb_server_addr [LB::server addr]
if { $lb_server_addr != "" } {
set lb_server_pool [LB::server pool]
set lb_server_status [LB::status pool $lb_server_pool member $lb_server_addr [LB::server port]]
if { $lb_server_status == "down" || $lb_server_status == "session_disabled" } {
Reselect active connections when pool member is out
Only do this if there are other active members available..
if { [active_members $lb_server_pool] > 0 } {
Only if the client is NOT requesting stateful things
Switch on path after partner, e.g. for /tenant/foo/bar.aspx, this switches on /foo/bar.aspx
if { ![class search persistencepaths starts_with [string tolower [HTTP::uri]]] } {
LB::detach
Delete any persistence record so we get a new one. The record is automatically
invalidated when server is DOWN, but not when DISABLED
if { [persist lookup source_addr [IP::client_addr] node] == $lb_server_addr } {
persist delete source_addr [IP::client_addr]
}
pool $lb_server_pool
}
}
}
}
}
/Patrik