Forum Discussion
iRule to block access to all but certain URIs
Only certain URIs are allowed on a server. I am trying to limit access to only those specific URIs. I have tried unsuccessfully to use the following iRule:
when HTTP_REQUEST {
if { not ([string tolower [HTTP::uri]] starts_with "/uri1") || not ([string tolower [HTTP::uri]] starts_with "/uri2") }{
HTTP::respond 200 content "URL Blocked"
}
}
This works fine if it is only one URI and the "or" is removed. Thoughts?
4 Replies
- What_Lies_Bene1
Cirrostratus
Try this;
Create a Data Group (called uriallow below) with the list of permitted URI's (make sure they start with /) when HTTP_REQUEST { if { not [class match [string tolower [HTTP::uri]] equals uriallow] } { HTTP::respond 200 content "URL Blocked" } Stop processing the iRule for this event here return } - What_Lies_Bene1
Cirrostratus
OK, slight update;Create a Data Group (called uri_allow below) with the list of permitted URI's (make sure they start with /) when HTTP_REQUEST { if { not [class match [string tolower [HTTP::uri]] equals uri_allow] } { HTTP::respond 200 content "URL Blocked" Stop processing the iRule for this event here Return } } - schmuck
Nimbostratus
Thank you. The bottom iRule worked. I changed the "equals" to "starts_with" and removed the Return. That did it though. Thank you very much.
- What_Lies_Bene1
Cirrostratus
Great. You're welcome.
The Return should have been all lowercase 'return' which probably explains your issue with that.
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