Forum Discussion
Bryce_Halkerst1
Nimbostratus
Apr 18, 2013iRule Data Group with string and regex
All,
Need to replace http class with with irule data group. Images are pretty straight forward, just need a little help with the regex images that are created on the http class.
HTTP Class
profile httpclass apache_content_httpclass {
defaults from httpclass
pool apache
redirect none
paths
"/*.gif*"
"/*.pdf*"
"/*.txt*"
"/*.css*"
"/*.GIF*"
"/*.SWF*"
"/*.PDF*"
"/*.TXT*"
"/*.CSS*"
"/*.flv*"
"/*.FLV*"
"/*.png*"
"/*.PNG*"
"/*.ico*"
"/*.swf*"
"/*.js"
regex ".*\\.js[^p]+.*"
glob "/*.JS"
regex ".*\\.JS[^p]+.*"
glob "/*.jpg*"
"/*.JPG*"
"/*.JPEG*"
"/*.jpeg*"
regex "(?i)^(?!.*\\.jsp).*\\.html?.*$"
glob "/*.eot*"
"/*ttf*"
"/*.ogv"
"/*.mpv"
"/*.webm"
"/*.m4v"
"/*.mp4"
}
6 Replies
Sort By
- What_Lies_Bene1
Cirrostratus
You can't use wildcards, regex's or glob patterns in a DG I'm afraid; everything is interpreted literally.
- Kevin_Stewart
Employee
As Steve said, classes don't support regex-style searches, but you can use the contains operator, which is functionally equivalent to "*something*". So while you may have to add more specific content type identifiers, the good news is that you can consolidate all of the oddly-cased variations of the same types by using a [string tolower ] match context. - Bryce_Halkerst1
Nimbostratus
Ok, so I am planning on doing something like this. - hoolio
Cirrostratus
Something like that should work. Else you could use a switch statement to check the file types in the iRule itself.when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "*.css" - "*.pdf" - "*.txt" - "*.flv" { Select the Apache pool for static filetypes pool Apache_Pool_80 } "/webservices*" - "/qas*" { pool Weblogic_Services_Pool } default { Select a pool for non-matching filetypes pool some_default_pool } } }
- hoolio
Cirrostratus
Here's an updated version of your approach:when HTTP_REQUEST { if {[class match -- [string tolower [HTTP::path]] ends_with images] } { pool Apache_Pool_80 } elseif { ([HTTP::path] ends_with ".gif") || ([HTTP::uri] ends_with "/qas") } { pool Weblogic_Pool } elseif {[HTTP::uri] starts_with "/webservices" } { pool Weblogic_Services_Pool } elseif {[HTTP::uri] contains "/atgws" } { pool buybuybaby.com_services_80 } else { pool Apache_Pool_80 } }
- Bryce_Halkerst1
Nimbostratus
All,
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