Yes, you can replace the HTTP::redirect with a pool statement.
For 9.4.4+ make sure to reference datagroups without the $:: or :: prefix. Else, the lookup will fail in 10.x. Also, you can replace matchchlass with class:
when CLIENT_ACCEPTED {
Check once per TCP connection if the country for the client IP is in the blocked country datagroup
if { [class match [whereis [IP::client_addr] country] eq blocked_countries] } {
pool blocked_pool
} else {
pool [LB::server pool]
}
}
Actually, the whereis was added in 10.1.0, so you’d need to be on that version or higher to use this iRule. If it’s not working on one of those versions, you can add debug logging:
when CLIENT_ACCEPTED {
log local0. "[IP::client_addr]:[TCP::client_port]: whereis: [whereis [IP::client_addr] country], class match: [class match [whereis [IP::client_addr] country] eq blocked_countries]"
Check once per TCP connection if the country for the client IP is in the blocked country datagroup
if { [class match [whereis [IP::client_addr] country] eq blocked_countries] } {
pool blocked_pool
} else {
pool [LB::server pool]
}
}