Forum Discussion
jkstraw_44238
Jun 18, 2008Nimbostratus
regex in iRules
Hello,
Please be patient with me - I am not the iRule guy on our team 🙂
We are using iRules primarily for redirecting URI's to specific pools - we do this with something similar to:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/site1*" -
"/site2*" -
"/site3*" -
"/site4*" {
pool Test_Pool
}
}
}
We have found that in our environment there are a number of security related issues (mainly fingerprinting) we need to address.
I would like to follow the philosophy of "block everything and allow only what is required" instead of being reactive and "allowing everything and blocking what problems as they occur".
To accomplish this I was hoping it would be possible to use regular expressions to accomplish this. That is - the regular expression would only allow "/site1*" but not "//site1*".
Is something like this possible with iRules?
- The answer to your question is yes, you can use regex's when needed. This can be done with the regexp command or the -regex option for switch. But, with that being said, I would highly suggest trying to find alternate ways to do things like this without full blown regular expressions.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site1*" - "/site2*" - "/site3*" - "/site4*" { pool Test_Pool } default { reject } } }
Recent Discussions
Related Content
Â
DevCentral Quicklinks
* 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
Discover DevCentral Connects