NGINX Documentation

GeoIP2

Create variables based on the client IP address, using the precompiled MaxMind GeoIP2 databases.

Module Info

MaxMind’s GeoIP2 database provides contextual data for a comprehensive profile of IP addresses, including geolocation data (region, state, city, postal code) and extra data (ISP, domain, connection type). Basing on these data, NGINX Plus will be able to perform different user differentiation strategies, for example, provide different type of content depending on a country.

Installation Instructions

  1. Install the GeoIP2 module.

    For Amazon Linux, CentOS, Oracle Linux, and RHEL:

    $ yum install nginx-plus-module-geoip2
    

    For Debian and Ubuntu:

    $ apt-get install nginx-plus-module-geoip2
    

    For SLES:

    $ zypper install nginx-plus-module-geoip2
    
  2. Put both of the load_module directives in the top‑level (“main”) context of NGINX Plus configuration file, nginx.conf:

    load_module modules/ngx_http_geoip2_module.so;
    load_module modules/ngx_stream_geoip2_module.so;
    
    http {
        # ...
    }
    
  3. Perform additional configuration as required by the module.

  4. Reload NGINX Plus to enable the module:

    $ nginx -t && nginx -s reload
    

More Info