Forum Discussion
irule to allow only certain uris
I'm trying to create an simple iRule that will allow only uris that are in the data group "allowed uris". My iRule is:
when HTTP_REQUEST {
if {[matchclass [HTTP::uri] equals "allowed_uris "]}
{forward}
else
{discard}
}
and the data group is defined as:
class allowed_uris {
"/site1/*"
"/site2/*"
"/site3/*"
}
When the iRule is enabled, it seems to discard all http requests. Is my data group syntax wrong or is there something wrong that I'm not seeing in our iRule?
7 Replies
- What_Lies_Bene1
Cirrostratus
This should work, note Data Groups interpret * literally, you can't use wildcards, remove these before trying this;when HTTP_REQUEST { if { [ class match [string tolower [HTTP::uri]] contains allowed_uris ] } { Stop processing the iRule for this event here return else { drop } } } - What_Lies_Bene1
Cirrostratus
Try these, found in a post by Hoolio; http://www.zytrax.com/tech/web/mobile_ids.html http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones
- scarnes_82101
Nimbostratus
Thanks,
When I try the iRule above, I'm getting:
01070151:3: Rule [allowed_uris] error: line 4: [wrong args] [return else { drop }]
Any thoughts? - What_Lies_Bene1
Cirrostratus
Sorry, a bracket was in the wrong place;when HTTP_REQUEST { if { [ class match [string tolower [HTTP::uri]] contains allowed_uris ] } { Stop processing the iRule for this event here return } else { drop } } - scarnes_82101
Nimbostratus
Removing the * from the data group and using the updated iRule works like a charm. Thanks for the assist. - What_Lies_Bene1
Cirrostratus
You've very welcome. - scarnes_82101
Nimbostratus
One additional note here, be sure to enter the uri strings in the data group all lowercase when using the string tolower cmd in your irule.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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