Forum Discussion
irule not being executed
The biggest issue I see is the conditional matching. The [HTTP::host] command returns the Host header value in the request URL (ex. www.domain.com), while the [HTTP::uri] command returns the URI portion of the URL (ex. /xxx). Your evaluation is trying to match the host name to both the host and the URI, which would never work. An example workaround might look like this:
when HTTP_REQUEST {
if { ( [string tolower [HTTP::host]] equals "xxx.xxx.xxx" ) and ( [string tolower [HTTP::uri]] starts_with "/xxx" ) } {
pool POOL-XXX
} elseif { ( [string tolower [HTTP::host]] equals "yyy.yyy.yyy" ) and ( [string tolower [HTTP::uri]] starts_with "/yyy" ) } {
pool POOL-YYY
}
}
The above should work, but it also does present a problem. What if the host is xxx.xxx.xxx and the URI is not /xxx? You should attempt to account for all of the possible ways that a client can make a request. Example:
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"xxx.xxx.xxx" {
if { [string tolower [HTTP::uri]] starts_with "/xxx" } {
pool POOL-XXX
} else {
...what to do if the URI isn't /xxx?
}
}
"yyy.yyy.yyy" {
if { [string tolower [HTTP::uri]] starts_with "/yyy" } {
pool POOL-YYY
} else {
...what to do if the URI isn't /yyy?
}
}
default {
...what to do if the Host is neither of the above?
drop?
}
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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