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
- 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.
Irule Data Group (should {} contain the value?)
ltm data-group internal /Common/images {
records {
.CSS { } Example .CSS {.CSS}
.FLV { }
.GIF { }
.JPEG { }
.JPG { }
.PDF { }
.PNG { }
.SWF { }
.TXT { }
.bmp { }
.css { }
.flv { }
.gif { }
.ico { }
.jpeg { }
.jpg { }
.js { }
.m4v { }
.mp4 { }
.mpv { }
.ogv { }
.pdf { }
.png { }
.swf { }
.ttf { }
.txt { }
.webm { }
}
type string
}
when HTTP_REQUEST {
if {[class match -value -- [string tolower HTTP::uri] contains images] } {
pool Apache_Pool_80
if { ([HTTP::uri] contains "/*.gif*") || ([HTTP::uri] contains "/qas*") } {
pool Weblogic_Pool
if {[HTTP::uri] contains "/webservices*" } {
pool Weblogic_Services_Pool
if {[HTTP::uri] contains "/atgws" } {
pool buybuybaby.com_services_80
} else {
pool Apache_Pool_80
}
}
}
}
} - 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 } } }
Another reply on its way.
Aaron - 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 } }
Aaron - Bryce_Halkerst1
Nimbostratus
All,
This was an issue with persistence not http classes. Issue resolved.
Thanks,
Bryce
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