iRule for cookie based load balancing
I am trying to create an iRule to load balance on cookie data. cookie Name- gcbSessionServer
I am using below code but it is giving error
May 31 11:10:20 ttncltmxza-p err tmm[17866]: 01220001:3: TCL error: /Common/cct-cobrowse-ct-test_pool_switch_rule - expected boolean value but got "" while executing "if { [HTTP::cookie exist "gcbSessionServer"] } { switch -glob ([HTTP::cookie value "gcbSessionServer"]) { ".Co-browse_TENCBSD0_Node1" { pool cct..."
when HTTP_REQUEST { if { [HTTP::cookie exist "gcbSessionServer"] } { switch -glob ([HTTP::cookie value "gcbSessionServer"]) { ".Co-browse_TENCBSD0_Node1" { pool cct-cobrowse-ct-node-1_pool } ".Co-browse_TENCBSD0_Node2" { pool cct-cobrowse-ct-node-2_pool } ".Co-browse_TENCBSD0_Node3" { pool cct-cobrowse-ct-node-3_pool } } } else { pool /Common/cct-cobrowse-ct.app/cct-cobrowse-ct_pool log local0. " Selected pool [LB::select] " } }
I am using below iRule and it works. I have single servers in pool and if the server is down LTM was throwing error.
when HTTP_REQUEST {
if { ([HTTP::cookie exists gcbSessionServer]) } {
if { ([HTTP::cookie value "gcbSessionServer"] contains ".Co-browse_TENCBSD0_Node1") and ([active_members cct-cobrowse-ct-node-1_pool] > 0)} {
pool cct-cobrowse-ct-node-1_pool
log local0. " COOKIE->[HTTP::cookie value "gcbSessionServer"] Selected pool [LB::select] " }
elseif { ([HTTP::cookie value "gcbSessionServer"] contains ".Co-browse_TENCBSD1_Node2") and ([active_members cct-cobrowse-ct-node-2_pool] > 0)} {
pool cct-cobrowse-ct-node-2_pool
log local0. " COOKIE->[HTTP::cookie value "gcbSessionServer"] Selected pool [LB::select] " }
elseif { ([HTTP::cookie value "gcbSessionServer"] contains ".Co-browse_TENCBSD2_Node3") and ([active_members cct-cobrowse-ct-node-3_pool] > 0)} {
pool cct-cobrowse-ct-node-3_pool
log local0. " COOKIE->[HTTP::cookie value "gcbSessionServer"] Selected pool [LB::select] " }
else {
LB::mode rr
pool /Common/cct-cobrowse-ct.app/cct-cobrowse-ct_pool
log local0. " COOKIE FOUND Selected pool [LB::select] "
} }
else {
LB::mode rr
pool /Common/cct-cobrowse-ct.app/cct-cobrowse-ct_pool
log local0. " NO COOKIE Selected pool [LB::select] "
} }