You can't use the
pool
command in LB_SELECTED as the load balancing decision has already been made.
Try placing your pool command in HTTP_REQUEST
(you also had a missing end quote in the switch)
https://devcentral.f5.com/wiki/iRules.pool.ashx
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/App1*" {
set port 80
}
"/App2*" {
set port 81
}
"/App3*" {
set port 82
}
}
if {([info exists port]) && ($port ne "")} {
pool [LB::server pool] member [LB::server addr] $port
}
}
PS - Pool command added inside an
if
, this is because the $port variable may not exist if a connection arrives with a different URI to the one in the switch statement. If this happens you'll get a TCL error.