Closed donbeave closed 10 years ago
Hi @donbeave
I think you should be able to achieve this by using ngx_http_realip_module (http://nginx.org/en/docs/http/ngx_http_realip_module.html).
Let me know if that suits your needs.
Cheers, Lee
Hi @leev
It not worked for me.
In nginx config I tried two variants:
1)
real_ip_header X-RemoteBackend-real-remote;
geoip2 /usr/local/share/GeoIP2-Country/GeoIP2-Country.mmdb {
$geoip2_data_country_code default=RU country iso_code;
}
2)
set_real_ip_from 119.161.140.138;
geoip2 /usr/local/share/GeoIP2-Country/GeoIP2-Country.mmdb {
$geoip2_data_country_code default=RU country iso_code;
}
I check the values by this log format:
log_format ns '[$time_local] $http_x_remotebackend_real_remote $geoip2_data_country_code';
And in the result I see:
[08/Jul/2014:22:40:05 +0800] 203.80.210.55/32 RU
[08/Jul/2014:22:42:20 +0800] 203.80.210.55/32 RU
I haven't used the realip module before, but did you try with both the real_ip_header and set_real_ip_from:
real_ip_header X-RemoteBackend-real-remote;
set_real_ip_from 119.161.140.138;
geoip2 /usr/local/share/GeoIP2-Country/GeoIP2-Country.mmdb {
$geoip2_data_country_code default=RU country iso_code;
}
Tried. But nothing changed...
There currently isn't any other way to do it. I can look at adding something like 'geoip2_ip $variable'.
Cool! Thank you. It's gonna be great!
I think the problem might be that you have the /32 on the end of the IP. Can you send through just the IP?
I have just tested using the realip module and sending through that header and it has worked.
Not worked, too. Can you share you config file?
set_real_ip_from 10.0.0.0/8;
real_ip_header X-RemoteBackend-real-remote;
geoip2 /usr/share/GeoIP/GeoIP2-Country.mmdb {
$geoip2_data_country_code default=GB country iso_code;
$geoip2_data_country_name default=UnitedKingdom country names en;
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" - '
'$geoip2_data_country_code $http_x_remotebackend_real_remote';
Sending the header: X-RemoteBackend-real-remote:8.8.8.8
Without realip: 10.192.4.10 - - [09/Jul/2014:13:19:30 +0000] "GET / HTTP/1.1" - GB 8.8.8.8 With realip: 8.8.8.8 - - [09/Jul/2014:13:20:04 +0000] "GET / HTTP/1.1" - US 8.8.8.8
As an update, you can now do this:
$geoip2_data_country_code default=GB source=$variable country iso_code;
@leev Thanks! Useful feature.
Hello!
Is it possible to specify from which variable read client IP?
I think to integrate this module with PowerDNS through remote backend, so it will be awesome if I can use
$http_x_remotebackend_real_remote
variable.