Forum Discussion
xuwen
Jul 20, 2022Cumulonimbus
# first create 3 pool,name is pool_node0, pool_node1, pool_default
# pool_node0 member 10.1.1.10:80 monitor tcp
# pool_node1 member 20.1.1.20:80 monitor tcp
# pool_default member 10.1.1.10:80 20.1.1.20:80 monitor tcp
iRuels code:
when RULE_INIT {
array set static::pool_array {
0 pool_node0
1 pool_node1
}
}
when HTTP_REQUEST {
if { [HTTP::cookie exists "JSESSIONID"] } {
set node_x [findstr [HTTP::cookie "JSESSIONID"] "serverID" 8 1]
log local0. "node_x is $node_x"
if { [active_members [lindex [array get static::pool_array $node_x] 1]] == 0 } {
pool pool_default
} else {
pool [lindex [array get static::pool_array $node_x] 1]
}
} else {
pool pool_default
}
}