3

I'm trying to install Nginx GeoIP module on centos6.
I'm using this guide to install it: How to install Nginx GeoIP module
But I face this problem when I try to set the path of GeoIp in nginx.cof:

nginx: [emerg] unknown directive "geoip_country" in /etc/nginx/nginx.conf:7 nginx:
configuration file /etc/nginx/nginx.conf test failed

And these are the lines I'v added to nginx.conf :

geoip_country /usr/local/share/GeoIP/GeoIP.dat;
geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;

I searched this issu in google, one answer was it should be in main{} section but when I insert main{} in nginx.conf and insert the lines in there, I see another error says main{} is wrong! Also I read somewhere else that main{} is the same nginx.conf file!
I'm so confused, Can anyone help me with this?


[UPDATE]
this is the http section in my nginx.conf:
http {
    include       /etc/nginx/mime.types;

    # For user configurations not maintained by DirectAdmin. Empty by default.
    include /etc/nginx/nginx-includes.conf;

    # Supplemental configuration
    include /etc/nginx/nginx-modsecurity-enable.conf;
    include /etc/nginx/nginx-defaults.conf;
    include /etc/nginx/nginx-gzip.conf;
    include /etc/nginx/directadmin-ips.conf;
    include /etc/nginx/directadmin-settings.conf;
    include /etc/nginx/nginx-vhosts.conf;
    include /etc/nginx/directadmin-vhosts.conf;

    geoip_country /usr/local/share/GeoIP/GeoIP.dat;
    geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;

# Set php-fpm 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;
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;
}

Is there any problem with it?

Alexander Jones
  • 103
  • 3
  • 11
  • you probably neeh to `load_module` if it is not `include`-ed elsewhere in the configuration file. –  Aug 22 '18 at 11:06

0 Answers0