Forum Discussion
Port Redirection Failure
I'm using a Non-Prod F5 running 12.1.2 Build 1.292.271.
We have a cluster of nodes that serve up various Apps on different ports.
/App1 - 80
/App2 - 81
/App3 - 82
I have configured a pool with members that have all service ports enabled. Also a single VS with a VIP and a service port of 0.
Here is my iRule:
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/App1*" {
set port 80
}
"/App2*" {
set port 81
}
"/App3* {
set port 82
}
}
}
when LB_SELECTED {
pool [LB::server pool] member [LB::server addr] $port
}
When running statistics on the iRule I get failures in the "LB_SELECTED" part however from my prospective this should be the correct syntax to change the service port on a pool. I would like some feedback on this configuration and if someone can comment on this configuration. Thanks.
- Lee_SutcliffeNacreous
You can't use the
command in LB_SELECTED as the load balancing decision has already been made. Try placing your pool command in HTTP_REQUESTpool
(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
, 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.if
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com