Forum Discussion
Patti_G_72768
Nimbostratus
Oct 01, 2013Regex rule conversion to iRule
Hi all, I'm a newbie and have been working on converting a regex rule to an iRule. I wanted to reach out to the community to see if I can get some help with what I have written so far. The regex rule...
Kevin_Stewart
Employee
Oct 01, 2013I think you could probably skip a strict regex implementation and use something like a set of data groups or a set of lists. Here's what it might look like with string-based data groups.
my_method_dg
"get" := ""
"head" := ""
"propfind" :=
"options" := ""
my_type_dg
"application/x-www-form-urlencoded" := ""
"multipart/form-data" := ""
"text/xml" :=
And the iRule:
when HTTP_REQUEST {
if { ( [class match [string tolower [HTTP::method]] contains my_method_dg] ) and ( [class match [string tolower [HTTP::header Content-Type]] contains my_type_dg] ) } {
log local0. "Request content type is not allowed by policy."
HTTP::respond 501 content "Request content type is not allowed by policy."
event disable
}
}
One other minor change was also required. The drop and HTTP::respond commands are mutually exclusive. One will respond with content and the other will simply drop the connection.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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