Forum Discussion
Chris_103315
Nimbostratus
Mar 04, 2008HTTP_REQUEST event bypassed?
I'm writing an iRule in our production environment to split traffic based on URI. All works fine except there is one request that seemingly doesn't fall into any case and is in turn load-balanced between the enabled nodes in default pool.
basically for all requests I want:
/forums -> node 1-3
/account -> node 4-6
/api -> "special pool" of 2 nodes
Everything else -> node 7-9
The problem is that I still see a single request (for example /forums/posts.aspx) go to all nodes when it should only go to 1-3. I also have verified that the request is serviced by the default pool of all 9 nodes by disabling all but a couple nodes and seeing that the /forums/posts.aspx only goes to the enabled nodes. The rest of the traffic is correctly segmented via the iRule. If this was a parse error on the URI this request should fall into the else block and only go to 7-9.
I want to use iRules to control all requests, but it seems there are circumstances "when HTTP_REQUEST" event doesn't fire or isn't caught. Does anyone know what might cause this?
An example of the iRule:
when HTTP_REQUEST priority 100
{
if {[string tolower [HTTP::uri]] starts_with "/forums/" }
{
pool POOL01_03
}
elseif {[string tolower [HTTP::uri]] starts_with "/account/" }
{
pool POOL04_06
}
elseif {[string tolower [HTTP::uri]] starts_with "/api/"}
{
pool POOLAPI
}
else
{
pool POOL07_09
}
}
- Nicolas_Menant
Employee
Hi, - Had to chime in. Duplicating "string tolower" on each of the if/elseif's is way too much overhead. I'd go with something like this:
when HTTP_REQUEST { log local0. "uri is [HTTP::uri]" switch -glob [string tolower [HTTP::uri]] { "/forums/*" { log local0. "POOL01_03 used" pool POOL01_03 } "/account/*" { log local0. "POOL04_06 used" pool POOL04_06 } "/api/*" { log local0. "POOLAPI used" pool POOLAPI } default { log local0. "default pool POOL07_09 used" pool POOL07_09 } } }
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