You can use following code (it assign the pool at the beginning to remove else statements):
when HTTP_REQUEST {
pool POOL-443
set preferedMember [list]
switch [HTTP::cookie value cookiecrisp] {
"azul" {
set preferedMember [list "172.16.1.21" 443 "172.16.1.22" 443]
}
"rojo" {
set preferedMember [list "172.16.1.23" 443 "172.16.1.21" 443]
}
"amarillo" {
set preferedMember [list "172.16.1.22" 443 "172.16.1.23" 443]
}
}
foreach {memberip memberport} $preferedMember {
if { [LB::status pool $default_pool member $memberip $memberport] eq "up" } {
pool POOL-443 member $memberip $memberport
break
}
}
}
I'm not sure the persistence is useful! I guess you can remove it.
The persistence record will match only is cookie value is the same as the previous request and the server is alive. so persistence is only done by cookie value.