Forum Discussion
Richard_Kim_270
Nimbostratus
Jan 11, 2007iRule for starts with "reports/" data group?
I'm looking for an iRule that will redirect the request to a pool if the URL contains a "/reports/* in the URL path. Currently I am using:
when HTTP_REQUEST {
if { [matchclass [...
Jan 11, 2007
That should work for you. The only problem with the contains operator is that it acts like "*string*" so for report the following urls would workhttp://host/report/foo
http://host/foo/report
http://host/foo/fooreport
http://host/foo/bar?report=1
If you just want uris that start with "/report", "/admin", "/reports", you might want to use the starts_with operator as opposed to using contains.
Also, If you only have a handful of strings, a data group might not be the easiest to manage. You can expand my above switch statement to the following:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/admin/*" -
"/report/*" -
"/reports/*" {
pool RP_pool_1
}
}
}This will only match uri's that start with the strings in your report class.
But, if you really do want to just search for that string anywhere in the uri you could also do this with a switch statement
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"*/admin/*" -
"*/report/*" -
"*/reports/*" {
pool RP_pool_1
}
}
}If data groups work for you and you want to make sure the strings are at the beginning of the uri I'd suggest you change it to this:
when CLIENT_ACCEPTED {
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
if { [matchclass [string tolower [HTTP::uri]] starts_with $::Report_strings_matchclass] } {
pool RP_pool_1
} else {
pool $default_pool
}
}and make sure your Reports_strings_matchclass datagroup looks like this:/admin/
/report/
/reports/
One other thing to note. I'm not sure it's needed for you to manually assign the pool with the value of the [LB::server pool]. If it's the default pool in the vs profile, then why set it again? It's already set to that value.
So many ways to do the same thing. You decide which is best for you.
-Joe
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
