Forum Discussion
How to use a Datagroup of URI Strings to compare and select pool based on HTTP :: Path
HI ,
I have a scenario , I am trying to use do pool selection by comparing the starts_with part of the http::path with consecutive URI included in a Datagroup .
More over , when i try to do the compare with http:uri starts_with , I am getting a tcl error with class match .
Error :
TCL error: /Common/xyz...-irule <HTTP_REQUEST> - bad action "match/a/b/x": must be match, search, lookup, element, type, exists, size, names, get, startsearch, nextelement, anymore, or donesearch while executing "class match[string tolower [HTTP::path]] equals "URI_datagroup""
My condition is the URI startswith /a/b/ is fixed whereas the next part of URI is a variable which can be x or y
I have to select the pool based on x or y prior to that /a/b is fixed
Hi Shripaty,
This error is caused by no space after "match".
if { [class match [string tolower [HTTP::path]] equals URI_datagroup] } {
- Shripaty
Cirrus
Thanks , for the hint , but still i am not able to match the consecutive http path with the URI listed in the datagroup
I am trying to match
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] starts_with "/a/b") and ([class match [string tolower [HTTP::path]] eq x_URI_list) } {
pool x_pool
}elseif {([string tolower [HTTP::uri]] starts_with "/a/b") and ([class match [string tolower [HTTP::path]] eq y_uri_list]) } {
pool y_pool
}else {
reject
}
}
}
Does the datagroup strings contain "/a/b"?
Can you try this iRule?
when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with "/a/b" } { set newPath [string map {"/a/b" ""} [HTTP::path]] # log local0. "Path without /a/b: $newPath" if { [class match [string tolower $newPath] equals x_uri_list] } { pool x_pool } elseif { [class match [string tolower $newPath] equals y_uri_list] } { pool y_pool } else { # reject } } else { # reject } }
Recent Discussions
Related Content
* 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