Forum Discussion
naladar_65658
Altostratus
Nov 20, 2008A Problem with Datagroup Usage
I am having problems with an iRule that uses datagroups. For some reason it just doesn't seem to work at all. Would you fellas mind taking a look at it and maybe point out any grammatical or logic e...
hoolio
Cirrostratus
Nov 20, 2008HTTP::uri returns the full URI. For a URL like:
http://www.example.com:80/path/to/index.jsp?param1=value1¶m2=value2
[HTTP::host] = www.example.com:80
[HTTP::uri] = /path/to/index.jsp?param1=value1¶m2=value2
[HTTP::path] = /path/to/index.jsp
[HTTP::query] = param1=value1¶m2=value2
So as long as the requested URI contains the leading and trailing forward slashes (like /dco/test.jsp) it should match the datagroup element, /dco/ using starts_with. If the datagroup had a trailing slash, but the requested URI didn't, then matchclass would return false.
Here is a quick example:
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::uri]"
set header_uri [string tolower [HTTP::uri]]
log local0. "[IP::client_addr]:[TCP::client_port]: \$header_uri: $header_uri"
if {[matchclass $header_uri starts_with $::www8_uri]} {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched www8_uri dg"
pool WWW8_Pool
} elseif {[matchclass $header_uri starts_with $::oam_uri]} {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched oam_uri dg"
HTTP::redirect "https://blank.blank.com/oam/main/oamMain.jsp"
} else {
log local0. "[IP::client_addr]:[TCP::client_port]: No match"
log local0. "[IP::client_addr]:[TCP::client_port]: dg's: \$::www8_uri: $::www8_uri, \$::oam_uri: $::oam_uri"
pool WWW2_Pool
}
}
And the log output for a request to /dco (shouldn't match the datagroup) and one to /dco/ (should match):
: 10.40.6.136:1394: New HTTP request to /dco
: 10.40.6.136:1394: $header_uri: /dco
: 10.40.6.136:1394: No match
: 10.40.6.136:1394: dg's: $::www8_uri: /dco/ /www1 /www2, $::oam_uri: /oam1/ /oam2 /oam3
: 10.40.6.136:1396: New HTTP request to /dco/
: 10.40.6.136:1396: $header_uri: /dco/
: 10.40.6.136:1396: Matched www8_uri dg
Aaron
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
