Answer the question
In order to leave comments, you need to log in
How to fix an error when building Nginx with GeoIP module?
Welcome all. I need your help.
Situation:
I'm trying to set up a server so that the site is available only for RF users, i.e. to make 403 forbidden open to all other countries.
I found a more or less understandable manual and did the following:
1. Checking nginx -V showed that --with-http_geoip_module exists and is already enabled
2. Downloaded sudo wget geolite.maxmind.com/download/geoip/database/GeoLit...
sudo wget geolite.maxmind.com/download/geoip/database/GeoLit...
3. Unpacked to /etc/nginx/geoip/ GeoLite2-Country.mmdb and GeoLite2-City.mmdb
4. Added to nginx.conf in http:
geoip_country /etc/nginx/geoip/GeoLite2-Country.mmdb;
geoip_city /etc/nginx/geoip/GeoLite2-City.mmdb;
map $geoip_country_code $bad_country {
default 1;
include /etc/nginx/geoip/good_countries;
}
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code;
fastcgi_param GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3;
fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name;
fastcgi_param GEOIP_REGION $geoip_region;
fastcgi_param GEOIP_CITY $geoip_city;
fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
fastcgi_param GEOIP_LATITUDE $geoip_latitude;
fastcgi_param GEOIP_LONGITUDE $geoip_longitude;
fail
nginx: [emerg] invalid GeoIP City database "/etc/nginx/geoip/GeoLite2-City.mmdb" type:1 in /etc/nginx/nginx.conf:94
nginx: configuration file /etc/nginx/nginx.conf test failed
geoip_city /etc/nginx/geoip/GeoLite2-City.mmdb;
Answer the question
In order to leave comments, you need to log in
ngx_http_geoip_module does not support GeoIP2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question