Forum Discussion
Rodney_Newton_7
Nimbostratus
Sep 21, 2006Pool selection using uri variables
I have a unit in test where test sites are added frequently so I am constantly adding pools to the bigip and using and iRule for pool selection similar to the following.
when HTTP_REQUEST {
if {[HTTP::uri] contains "test1"}
{pool testbed-test1}
elseif {[HTTP::uri] contains "test2"}
{pool testbed-test2}
elseif {[HTTP::uri] contains "test50"}
{pool testbed-test50}
else {pool defaultpool}
}
The uri hitting the vip looks like this... http://hostname/xx-test1, http://hostname/xx-test50, etc...
It would be nice if I could just add the new pool and not have to edit my iRule each time. Is there a way that I can parse the info from the uri into a variable then use that variable as part of the pool name in the selection statement? Keep in mind that the varaible portion of the pool name will be after the "xx-" in the uri and could be 4 or 5 characters in length. Thanks for any input.
- hoolio
Cirrostratus
Hi,when HTTP_REQUEST { set my_pool "http_pool" pool $my_pool }
- Deb_Allen_18Historic F5 Accounthoolio is right, but you do sort of need to be a bit careful when using dynamic data to build a pool name, though.
when HTTP_REQUEST { extract the pool info from the URI set uristring [findstr [HTTP::uri] "xx-" "/"] check if the pool exists and has avail members if {[active_members "testbed-$uristring"] > 0}{ pool testbed-$uristring } else { pool defaultpool } }
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