Forum Discussion
CGI
May 05, 2012Altostratus
Optimizing Irule
Hi below is a rule being used together with geofilter and looking at the specific uri and then sending requests to different pools based on the Country, is there a more effective way todo the same thi...
hooleylist
May 07, 2012Cirrostratus
Hi Craig,
Here's an example which minimized the repeated commands with an intermediate variable for the country code:
when CLIENT_ACCEPTED {
set cc [whereis [IP::client_addr] country]
if { [class match $cc eq Allowed_Country_Test] or [class match [IP::client_addr] eq allowed_ip] } {
set allowed 1
} else {
set allowed 0
}
}
when HTTP_REQUEST {
if { $allowed } {
switch $cc {
"FI" -
"DK" {
if {[HTTP::uri] contains "/compass/" } {
pool Compass${cc}_Test_http_pool
} else {
pool Compass_Test_http_pool
}
}
default {
pool Compass_Test_http_pool
}
}
} else {
do whatever you want to indicate the block, e.g.
HTTP::respond 403 content "The country or IP is not allowed to access this site"
}
}
Aaron
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