Forum Discussion
Paedrig_69869
Nimbostratus
Sep 20, 2016iRule to process URI and Header data groups
Hi All,
I am trying to create an iRule that will match certain URIs against a data-group to decide which pool to send it to and then if no matching URI inspect the header and check against another ...
Michael_Jenkins
Cirrostratus
Sep 20, 2016Apart from adding the hostname and path in your datagroup, you could use other datagroups to handle that... Untested, but perhaps something similar to this:
when HTTP_REQUEST {
set hostLower [string tolower [HTTP::host]]
set pathLower [string tolower [HTTP::path]]
Use a datagroup matched on the host name that will give you the name of another datagroup to use to look up the pool redirect
if { [class match $hostLower starts_with dg_host_dg_lookup] } {
set dgName [class match -value $hostLower starts_with dg_host_dg_lookup]
Now check the correct datagroup for the path
if { [class match $pathLower starts_with $dgName] } {
pool [class lookup $pathLower $dgName]
return
}
If that didn't work, check for the header value
if { [HTTP::header exists remote.contenttype] && [HTTP::header remote.contenttype] equals dg_header_pool_redirect } {
pool [class lookup [HTTP::header remote.contenttype] dg_header_pool_redirect]
return
}
}
}
You'd need to add additional data-groups for each host (which includes the hostname:port)
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