Reputation: 14406
I follow nginx geoip configuration guide here http://www.howtoforge.com/nginx-how-to-block-visitors-by-country-with-the-geoip-module-debian-ubuntu
I write something like this
geoip_country /path/to/GeoIP.dat;
I am pretty sure the .dat file is there, and nginx has permission to access it. However, the geoip_country_code
variable seems not set.
I've tried many approaches to debug, like
add_header X-debug-message "$geoip_country_code";
or
log_format debug "$geoip_country_code"
for header, nginx returns empty result. And for log format, it simply record nothing. My bet is geoip_country_code is not even defined, so nginx cannot deal with it or what.
I tried to read the server error log, however, nothing there (nothing about geoip and the undefined variable). It's kinda annoying, how can I know what's going on with nginx and the geoip module?
Upvotes: 3
Views: 4659
Reputation: 5256
A way to debug could be checking the environment for the GEOIP variables, e.g. in PHP look in the $_SERVER
array, or try getenv(GEOIP_COUNTRY_CODE)
.
Make sure to define the variables in /etc/nginx/fastcgi_params
:
### SET GEOIP Variables ###
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
Upvotes: 1
Reputation: 14406
After looking into syslog, I noticed that it's a segfault in geoip module
Aug 10 12:55:39 web kernel: [1183521.905522] nginx[30201]: segfault at 7fa773b7f2ce ip 00007fa772bc5478 sp 00007fffe4adc570 error 4 in libGeoIP.so.1.6.0[7fa772bbe000+2d000]
So, I bet it's caused either by geoip module or corrupted GeoIP.dat file. After looking into the file, I found that it's corrupted. Then I download the file again, everything works fine now.
Upvotes: 2