Forum Discussion
Vincent_Power_9
Nimbostratus
Jul 03, 2007Performance Question in Large iRule
I run into this situation a lot, where an iRule will look like this (our business users want everything behind one hostname/port).
Historically we've been building them like this since it is quic...
Deb_Allen_18
Jul 03, 2007Historic F5 Account
Not sure why switch -glob wouldn't do the trick:
switch -glob [string tolower [HTTP::uri]]{
/abc/* -
/bcd/* -
...
/jkl/* { pool one }
/klm/* -
/lmn/* -
...
/nop/* { pool two }
/opq/* -
/pqr/* -
...
/rst/* { pool three }
}
Or if you're going to switch only on the first level directory, you could avoid -glob switch if you parse out just that value for comparison:
switch [getfield [string tolower [HTTP::uri]] / 2] {
abc -
bcd -
...
jkl { pool one }
klm -
lmn -
...
nop { pool two }
opq -
pqr -
...
rst { pool three }
}
Or you could use a class listing the first directory and pool with a findclass (maintaining the list in the class instead of the iRule is probably easier administratively.)
Class:
class VirtualHosts {
abc one
bcd one
...
rst three
}
iRule snip:
set myPool [findclass [getfield [string tolower [HTTP::uri]] / 2] $::VirtualHosts " "]
if {$myPool != "" }{
pool $myPool
}
HTH
/deb
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects