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 member. I've come up with the following iRule. Can anyone tell me whether or not this is a sound iRule or if there is anything better I should write?
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 }
}
}