Forum Discussion
Clint_Byrum_103
Nimbostratus
Mar 16, 2006Simple HTTP::uri rule doesn't work as expected
I'm very new to iRules, just got our LTM recently.
I setup a rule like this:
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/jsfeatured.php"} {
pool jsfeatured_pool_80
} elseif {[string tolower [HTTP::uri]] starts_with "/js.php"} {
pool jobsearch_pool_80
}
}
My goal here is simple. If the user requests /jsfeatured.php, send them to the jsfeatured pool. If they're requesting /js.php, send them to the jobsearch pool. Otherwise, let it fall through to the virtual server's default pool.
Whats happening is requests to
/texis/jobseeker/
Are ending up in the jsfeatured pool, when they have a Referer: header of http://xxxxxx/jsfeatured.php
This just doesn't seem like what I want _AT ALL_.
I tried making it
when HTTP_REQUEST {
if {[string tolower [URI::query [HTTP::uri]]] starts_with "/jsfeatured.php"} {
pool jsfeatured_pool_80
} elseif {[string tolower [HTTP::uri]] starts_with "/js.php"} {
pool jobsearch_pool_80
}
}
But that made the rule never match the /jsfeatured.php, sending all of that traffic through to the default pool.
Am I missing something here? It doesn't seem to me like HTTP::uri should be matching stuff in _any_ of the headers. I only want to match whats on that first line.
Thanks!
4 Replies
Sort By
- You are doing everything correctly and it should work. The value HTTP::uri does not contain any header values so odds are something else is amiss.
when HTTP_REQUEST { log local0. "Requested URI: [HTTP::uri]" if {[string tolower [HTTP::uri]] starts_with "/jsfeatured.php"} { log local0. "URI: [HTTP::uri] matched /jsfeatured.php" pool jsfeatured_pool_80 } elseif {[string tolower [HTTP::uri]] starts_with "/js.php"} { log local0. "URI: [HTTP::uri] matched /js.php" pool jobsearch_pool_80 } else { log local0. "URI: [HTTP::uri] not matched" } }
- unRuleY_95363Historic F5 AccountFYI - this is caused be keepalive requests... If you don't explicitly select the pool, the last pool selection stands. Since multiple requests, may come on the same connection, it's a good idea to always have an else clause to pick the default pool.
when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { if {...} { pool a } elseif {...} { pool b } else { pool $default_pool } }
- Looks like unRuleY beat me to the punch...
- Clint_Byrum_103
Nimbostratus
Thats perfect! Thanks!
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