FishNiX_29746
Jan 25, 2010Nimbostratus
HOST/URI to pool mapping via iRule and class and trailing /
Greetings -
I'm attempting to write a generic iRule to send traffic for a URI to a specific pool. I will use this over "many" virtuals with "many" URIs.
I've chosen to use a class to store the mappings:
class host_uri_pool_selector_class {
"docs.foobar.edu /foo/ opa_pool"
"docs.foobar.edu /foobar/ baz_pool"
"test.foobar.edu /bar/ bar_pool"
}
rule set_pool_by_host_and_uri {
when HTTP_REQUEST {
foreach row $::host_uri_pool_selector_class {
if { [string tolower [HTTP::host]] equals [getfield $row " " 1] }{
if { [string tolower [HTTP::uri]] starts_with [getfield $row " " 2] }{
pool [getfield $row " " 3]
}
}
}
}
}
What's the most efficient way to check for the / at the end of each URI so that /foo and /foobar are not matched by whichever hits first but the URI still works in a browser without the trailing /?
Any other easy way to do this? I want people to easily be able to modify the class and to have a central location for this data. Can I use findclass or matchclass to make this faster?
EDIT: sorry about the blockquote, hopefully code tags will fix it....