Forum Discussion
Rodney_Newton_7
Nimbostratus
Oct 05, 2005iRule Syntax
Can someone show me the equivalent syntax for the following 4.x iRule for version 9.x?
if (http_header("User-Agent") contains "test") {
use pool bot
}
else {
i...
Oct 05, 2005
A direct mapping would be something like this (using elseif's instead of nested if's):
when HTTP_REQUEST {
if { [HTTP::header "User-Agent"] contains "test" } {
pool bot
} elseif { [IP::addr "[IP::client_addr]/24" equals "1.1.1.0/24"] } {
pool test
} elseif { [IP::addr "[IP::client_addr]" equals "2.2.2.2"] } {
pool test
} elseif { [IP::addr "[IP::client_addr]" equals "3.3.3.3"] } {
pool test
} elseif { [IP::addr "[IP::client_addr]" equals "4.4.4.4"] } {
discard
} elseif { [HTTP::header "User-Agent"] contains "test2" } {
pool test
} elseif { [HTTP::header "User-Agent"] contains "test3" } {
pool test
} elseif { [HTTP::header "User-Agent"] contains "test.test.com" } {
pool test
} else {
pool otherpool
}
}You could probably optimize this a bit by using data groups in combination with the matchclass command to combine a couple of those elseif's into a single. Right now the rule isn't too long, but if there were more User-Agent conditions tested all resulting in the same pool command then a matchclass approach might be more manageable.
-Joe
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
