For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

atoth's avatar
atoth
Icon for Cirrus rankCirrus
Aug 10, 2015

How to do a NOT URI with switch -glob

There is a VIP with an irule on it using the switch -glob format. Something like

switch [HTTP::uri] {
"/foo/* -
"/bar/* { pool blah 
} default { pool default
}
}

Now the application team that own the VIP would like to change that to something like

switch [HTTP::uri] {
**NOT** "/foo/* -
"/bar/* { pool blah 
} default { pool default
}
}

So that if the conditions do not match either /foo/ or /bar/, than redirect to pool blah. Not sure what the right syntax for that would be.

1 Reply

  • Without resorting to regular expression matching (which should be avoided), I believe there is no way to do the kind of negation that you are describing with a

    switch
    . This leaves you with two options:

    switch [HTTP::uri] {
        "/bar/*"    { pool blah }
        default {
            if { !([HTTP::uri] starts_with "/foo/") } {
                pool blah
            }
            else {
                pool default
            }
        }
    }
    

    or

    if { [HTTP::uri] starts_with "/bar/" || !([HTTP::uri] starts_with "/foo/") } { pool blah }
    

    then just set the VS default pool to "default". Unhappily, in this, you can't avoid the double-evaluation in the worst case.