Forum Discussion

Clint_Denham_16's avatar
Clint_Denham_16
Icon for Nimbostratus rankNimbostratus
Jul 05, 2007

Outage Pool with Redirect to '/'

Hi all - I've found enough info to get a basic rule setup tath does what I want, but now my app team wants to get all fancy on me.

My basic rule is "if the PRODUCTION pool is down, use the outage pool and send all requests to '/'


when HTTP_REQUEST {
 if { [active_members prod_pool] == 0 } {
    pool prod_outagepool }
 if { [active_members prod_pool] == 0 } {
    HTTP::uri / }
}

Lame, but effective....

Now the app team doesn't like this / redirect (rightfully so) and they want me to add exceptions to this so that the paths...

/outage

/portal

don't get caught on the "if { [active_members prod_pool] == 0 } {

HTTP::uri / }" redirect above.

Can anyone help me get the syntax right? I've tried this, but it doesn't pass the TCL syntax checker.


when HTTP_REQUEST {
 if { [active_members prod_pool] == 0 } {
    pool prod_outagepool }
 if { ( [active_members prod_pool] == 0 ) and ( [HTTP::uri] begins_with "/outage" ) } {
    HTTP::uri /outage }
 elseif { [active_members prod_pool] == 0 } {
    HTTP::uri / }
}
  • There is no "begins_with" operator. Use the "starts_with" operator and you should be set!

    when HTTP_REQUEST {
     if { [active_members prod_pool] == 0 } {
        pool prod_outagepool }
     if { ( [active_members prod_pool] == 0 ) and ( [HTTP::uri] starts_with "/outage" ) } {
        HTTP::uri /outage }
     elseif { [active_members prod_pool] == 0 } {
        HTTP::uri / }
    }

    A list of F5 specific operators (in addition to the standard TCL operators) is listed here:

    http://devcentral.f5.com/wiki/default.aspx/iRules.Operators

    Click here

    -Joe
  • Ahh - that's much cleaner. I'm digging into the 'switch' command (I haven't used it before) but the logic is correct. Thanks again!