Forum Discussion
iRule to drop if uri starts with specific word.
Customer have requiment that if there URI starts with /abc/* then drop the request.
For this I created below iRule after applying this all traffic was getting drop. Please suggest what I missed.
when HTTP_REQUEST { set lowerCaseUri [ string tolower [HTTP::uri] ] if { ($lowerCaseUri starts_with "/abc") } { reject } }
3 Replies
The only thing I see is that you specified you wanted anything starting with "/abc/" to be rejected. In the iRule you have anything starting with "/abc". Not sure if that's what you intended or not. I couldn't save that iRule as-is due to parsing errors. Try this
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/abc/" } { log local0. "Rejecting "/abc/* request" reject } }This should print a message to the /var/log/messages file everytime a /abc/* request comes in. /var/log/messages should also print out any errors you are having.
-Joe
- Vijay_E
Cirrus
You can certainly use "contains" instead of "starts_with" but will it achieve the functionality that you are seeking ? I think you need to discuss with the customer to understand the function required and also inform him of what exactly your iRule will do before implementing.
I would recommend logging the actual URI that is being dropped to compare:
Using Joe's iRule:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/abc/" } { log local0. "Rejecting [HTTP::uri] request" reject } } - jerodingo_26643
Nimbostratus
Hi, can we use http::URI starts_with and give a list of string instead? Jerodingo
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