Forum Discussion
F5Hopper_28651
Aug 15, 2016Nimbostratus
Geolocation irule for states
so I have read many irules on the dev site, creating mine.
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] starts_with "/testingpage") } {
Parse the client IP from the CDN header
...
F5Hopper_28651
Aug 16, 2016Nimbostratus
ok I figured it all out.. Imperva/Incapsula has added another header it passes its original client ip in called [HTTP::header "Incap-Client-IP"]
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] starts_with "/testingpage") } {
Parse the client IP from the CDN header
set client_ip [HTTP::header "Incap-Client-IP"]
log local0. "XFF: [HTTP::header "Incap-Client-IP"]"
if { $client_ip eq "" }{
The header was empty/did not exist, so use the actual client IP
set client_ip [IP::client_addr]
}
switch [whereis $client_ip abbrev] {
"NJ" -
"ID" {
HTTP::respond 200 content "Your IP IS from NJ or ID"
}
default {
set state [whereis $client_ip abbrev]
log local0. "Lowercase state is $client_ip"
HTTP::respond 200 content "Your IP IS NOT NJ or ID you is $state"
}
}
}
}
- janholtz_40468Aug 16, 2016Nimbostratus
Glad you got it sorted... Remember to comment out log local0.blah...
Extensive logging is good.
Until it isn't.
If you dont need it, switch it off :)
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