Forum Discussion
AllanUK_202329
Nimbostratus
Jan 12, 2017iRule for subdomain datagroup matching
Hi,
I have been trying to find a solution to my requirement below,
We have subdomains like subdomain.domain.com and we want to perform a match on the domain part in a data group to return a pool ...
Kai_Wilke
MVP
Jan 12, 2017Hi Allan,
which TMOS version are you running on? I'm asking because the
[findclass]
command and the way you're referencing the data-group (aka. via $::datagroup
) is deprecated since may years and would harm CMP-operations on current TMOS versions.
If you've loaded a TMOS version v10 or higher on your box, then the take a look to the iRule below. It uses the CMP-friendly
[class]
syntax to lookup the data-group containing the domain-to-pool information.
ltm data-group internal DG-HTTPSPool {
records {
"domain.com" {
data "pool-domain.com"
}
"domain.net" {
data "pool-domain.net"
}
}
type string
}
when HTTP_REQUEST {
if { [set pool [class match -value [domain [string tolower [getfield [HTTP::host] ":" 1]] 2] equals "DG-HTTPSPool"]] ne "" } then {
pool $pool
} else {
HTTP::respond 403 content "Access denied - Invalid HOST-name requested" "Content-Type" "text/html"
}
}
Cheers, Kai
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