Forum Discussion
iRule to redirect based on path plus fallback host
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 }
}
}
- Shahram_83722NimbostratusAnyone?
- Brian_69413Nimbostratusrather than an if statement inside the cases, just use the LB_FAILED event to catch when no pool members are available and assign to the fallback pool. I think this would be a more efficient way to handle this since both cases use the same fallback pool.
- hooleylistCirrostratusThe 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.
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 } } }
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 } }
- hooleylistCirrostratusPosted By Brian on 06/18/2012 01:01 PM
- Shahram_83722NimbostratusThank you guys for the input. I greatly appreciate it.
- hooleylistCirrostratusreturn exits out of the current event of the current iRule. So basically, the active_members check on the currently selected pool won't be run if the request is to a URI that's set for being dropped.
- Shahram_83722NimbostratusThank you Aaron. I'll use your rule and see how it goes.
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