Forum Discussion
Al_Faller_1969
Nimbostratus
Dec 22, 2005dropping HTTP requests to "other" URIs
Hi All -
I am trying to make an iRule that drops a request that is not destined for any of 4 different directories. Here is what I have so far, which hasn't been working:
when HTTP_REQUEST {
if { not [HTTP::uri] starts_with "/dir1" and
not [HTTP::uri] starts_with "/dir2" and
not [HTTP::uri] starts_with "/dir3" and
not [HTTP::uri] starts_with "/dir4"} {
drop
}
}
What am I doing wrong? Thanks!
Al
- JRahm
Admin
Change those and's to or's, or you could try this:when RULE_INIT { array set ::valid_dir { /dir1 /dir2 /dir3 /dir4 } } when HTTP_REQUEST { if { ![matchclass [string tolower [HTTP::uri]] starts_with $::valid_dir] } { discard } }
- JRahm
Admin
Use the rule I updated above in my post, I forgot the $, and I updated another syntax error (my specialty!) as well. - Al_Faller_1969
Nimbostratus
The UI accepts the code, but doesn't like it behind the scene. I still get the following error in the traffic manager log: - JRahm
Admin
Try a class instead. I added a log string to check to make sure the class is populated.class valid_dir { "/dir1" "/dir2" "/dir3" "/dir4" } when HTTP_REQUEST { log "Valid directories: $::valid_dir" if { not [matchclass [string tolower [HTTP::uri]] starts_with $::valid_dir] } { discard } }
- Al_Faller_1969
Nimbostratus
Bingo! - praveen_73358
Nimbostratus
Hi, - JRahm
Admin
sure, in that context it's referencing a datagroup, in later versions of 9.4 and all 10.x versions, you should remove the $:: as it demotes from CMP. The $:: can also reference a global variable set in RULE_INIT event. - Chris_Miller
Altostratus
Posted By Jason Rahm on 02/09/2011 08:09 AM - JRahm
Admin
Gave up the thought of ever catching you! - praveen_73358
Nimbostratus
Thanks a lot.
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