Forum Discussion
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