Forum Discussion
Icemanii_116694
Nimbostratus
Jan 02, 2014Block Opera Mini users using true client IP
I'm trying to restrict users from certain countries using Opera Mini browser from accessing my server. I'm using the following irule to replace the IP::client_addr field with the XFF IP:
when H...
nitass
Employee
Jan 08, 2014I've tried using the foreach, but I'm hitting Connection closed by remote server when using the opera mini browser trying to access my server.
can you post your latest irule?
by the way, i think $real_ip does not need square brackets, does it?
e.g.
[class match $real_ip equals WhitelistIP]
Icemanii_116694
Nimbostratus
Jan 09, 2014when CLIENT_ACCEPTED {
Save the name of the VS default pool
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
if { [string tolower [HTTP::header "User-Agent"]] contains "opera mini"} {
if {[HTTP::header exists "X-Forwarded-For"]} {
foreach real_ip [split [string map [list " " ""] [HTTP::header "X-Forwarded-For"]] ","] {
log local0. "IP matched is : $real_ip"
if {([class match [$real_ip] equals WhitelistIP]) } {
pool $default_pool}
elseif {([class match [$real_ip] equals BlacklistIP]) } {
HTTP::redirect "http://0.0.0.0"}
elseif { [class match [whereis $real_ip country] equals BlockedCountry]} {
HTTP::redirect "http://myforbiddenpage.com"
}
else {
pool $default_pool
}
}
}
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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