Forum Discussion
harton
Oct 04, 2013Nimbostratus
Irule with elseif and pool selection
Hello,
I'm trying to write an irule that routes traffic to a specific pool based on the host. I think I'm fairly close, but I can't figure out the following error:
01070151:3: Rule [test-pool-s...
RobertColbert
Oct 04, 2013Nimbostratus
The problem you have is you are starting with a switch and confusing the runtime with if statements.
If you want to use If's, then it would look more like this:
when HTTP_REQUEST {
set hostname [string tolower [HTTP::host]]
if { $hostname starts_with "abc" } {
pool ss-devsp3-pool
} elseif { $hostname starts_with "def" } {
pool ss-devsp3-pool-81
} elseif { $hostname starts_with "ghi" } {
pool ss-devsp3-pool-82
}
}
Using the switch statement, it would look more like this:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
abc* { pool ss-devsp3-pool }
def* { pool ss-devsp3-pool-81 }
ghi* { pool ss-devsp3-pool-82 }
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects