Trying to use GEOIP with nginx. nginx is configured --with-http_geoip_module and Maxmind free db is installed. I have tried two approaches, both fail.
Approach 1: In http section add:
geoip_country /root/GEOIP/GeoIP.dat; #path to geo db
Then try to use $geoip_country_code in server section, for example:
rewrite ^/(.*)$ http://$host:81/$1?country=$geoip_country_code permanent;
Result: returns empty geo variables. Appears to be missing some kind of invocation to the geo lookup.
Approach 2:
Based on forum posts for older nginx versions I tried fetching the .CSV version from Maxmind, converting it to nginx-compatible txt with the
contributed perl script, and including it in http section with:
geo $myCountry (
default no;
include /usr/local/nginx/conf/nginxGeo.txt
}
then in server section:
rewrite ^/(.*)$ http://$host:81/$1?country=$myCountry permanent;
Result: Browser page hangs then fails with server not responding. No redirection is supplied to address bar.
Please help, thanks!
Barry Q.