Forum Discussion
Trying to Block a small group of pages using an iRule
Hello all, new to the F5 world, attempting to write my first iRule. We need an iRule to block a hand full of pages. This is the iRule we built and would not let us in through the F5 once we attached the iRule to a virtual server.
Second attempt
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri ]] { "/apscript.html" - "/appdet.html" { reject } default { return } } }
First attempt
when HTTP_REQUEST { switch [string tolower [HTTP::uri ]] { "/apscript.html" - "/appdet.html" - "/aplogon.html" { drop } } }
We are running version 11 of F5, we want to drop the 2 pages and allow everything else through.
9 Replies
- Brad_Parker_139
Nacreous
Almost there.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/apscript.html" - "/appdet.html" { reject } default { return } } }- david_blake_230
Nimbostratus
I need to add a condition to block "/webtools/*" how can that be accomplished? - Brad_Parker_139
Nacreous
just add it like this: when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/apscript.html" - "/appdet.html" { reject } "/webtools/*" { do something } default { return } } } - Brad_Parker_139
Nacreous
or if you are just wanting it to reject like the other two, when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/apscript.html" - "/appdet.html" - "/webtools/*" { reject } default { return } } }
- Brad_Parker
Cirrus
Almost there.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/apscript.html" - "/appdet.html" { reject } default { return } } }- david_blake_230
Nimbostratus
I need to add a condition to block "/webtools/*" how can that be accomplished? - Brad_Parker
Cirrus
just add it like this: when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/apscript.html" - "/appdet.html" { reject } "/webtools/*" { do something } default { return } } } - Brad_Parker
Cirrus
or if you are just wanting it to reject like the other two, when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/apscript.html" - "/appdet.html" - "/webtools/*" { reject } default { return } } }
- Hannes_Rapp
Nimbostratus
You're were quite close. Try the code below.
Cause:
Your
function had unnecessary appendix[HTTP::uri]
Mere recommendations:
the
function will suffice here[HTTP::path]
flag in the switch statement is not required since you dont have any specific expressions such as wildcard symbols-globwhen HTTP_REQUEST { switch [string tolower [HTTP::path]] { "/apscript.html" - "/appdet.html" { drop } default { return } } }
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