Forum Discussion
Filtering a list of URLs
To start off, I'd like to mention that I am pretty new at this F5 business (been reading on it for about 2wks).
I am trying to find the best way to filter a list of URLs. Below is the current iRule that we are using, but as you can imagine as the need for additional URLs to be added to the iRule arises, it will be harder to keep track of them. So as a different solution, I would like to be able to insert a new URL into a list instead of having to create an "elseif" statement everytime.
Any help will be greatly appreciated :)
when HTTP_REQUEST {
where member is the parameter name
set member_param_1 "/mailSchedulingServices/mailSchedulingService.svc"
set member_param_2 "/cardPayMatrixSvc/cardPayMatrixSvc.svc"
set response_data "Unauthorized request"
if {[string match $member_param_1 [HTTP::path]]}{
Do nothing
}
elseif {[string match $member_param_2 [HTTP::path]]} {
Do nothing
} else {
log local0. "Compare response with $member_param"
HTTP::respond 200 content $response_data
}
}
- hoolio
Cirrostratus
Hi,class whitelist_paths_class { { "/cardPayMatrixSvc/cardPayMatrixSvc.svc" "/mailSchedulingServices/mailSchedulingService.svc" } }
when RULE_INIT { set static::block_html {Access denied!} } when HTTP_REQUEST { if { not [class match [HTTP::path] equals whitelist_paths_class]}{ HTTP::respond 200 content $static::block_html } }
- Born_7758
Nimbostratus
Thank you Aaron!Is there a way to do it without using datagroups?
The reason I ask is because I was given this assignment as a "good starting point" to understand iRules. The person that assigned this task to me asked me to see if there is a way to do it using the "array" syntax.
- Born_7758
Nimbostratus
When I tried your suggestion I get an error saying: - Born_7758
Nimbostratus
When I tried your suggestion I get an error saying: - Born_7758
Nimbostratus
When I tried your suggestion I get an error saying: - hoolio
Cirrostratus
If the class command doesn't exist, you're running v9. You can use matchclass instead:when HTTP_REQUEST { if { not [matchclass [HTTP::path] equals whitelist_paths_class]}{ HTTP::respond 200 content {Access denied!} } }
- Born_7758
Nimbostratus
Ok. I really appreciate all the help. - hoolio
Cirrostratus
matchclass looks up to see if the HTTP::path value exactly matches any entry in the datagroup named "whitelist_paths_class". Then not negates that. So if the requested path isn't in the datagroup, a 200 response is sent back to the client with the HTML content. - Born_7758
Nimbostratus
Sweet thanks! :) - Born_7758
Nimbostratus
I edited your suggestion and rewrote it like this so that I don't use Run_init ...when i use this it looks like i am no longer to connect to that URL through the browser
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