Forum Discussion
Shahram_83722
Jun 16, 2012Nimbostratus
iRule to redirect based on path plus fallback host
I'm not super on iRules but need to write one that will redirect path A and B to pool1 and path C and D to pool2. I also need to incorporate a fallback host in case each of these pools don't have a me...
hooleylist
Jun 18, 2012Cirrostratus
The rule you have looks okay. The curly braces weren't exactly correct, but I assume that's just an issue with the editing you did for the post.
Here's your original version with balanced braces:
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::path]] {
"/a*" -
"/b*" {
if {[active_members pool_1] < 1} {
Log and direct the client to Maintenance pool
log local0. "!!Maintenance page called for Pool1!!"
pool Fallback_Pool
} else {
pool pool_1
}
}
"/c*" -
"/d*" {
if {[active_members pool_2] < 1} {
Log and direct the client to Maintenance pool
log local0. "!!Maintenance page called for Pool2!!"
pool Fallback_Pool }
else {
pool pool_2
}
}
default {
discard
}
}
}
You could move the active_members check of the pool outside the switch statement to simplify the rule a little:
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::path]] {
"/a*" -
"/b*" {
pool pool_1
}
"/c*" -
"/d*" {
pool pool_2
}
default {
discard
return
}
}
if {[active_members [LB::server pool]] < 1} {
Log and direct the client to Maintenance pool
log local0. "!!Maintenance page called for [LB::server pool]!!"
pool Fallback_Pool
}
}
Aaron
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