NGINX Documentation

GeoIP2

Create variables based on the client IP address, using the precompiled MaxMind GeoIP2 databases, which provide localized name information not present in the original GeoIP databases.

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
    
  2. Put both of the following directives in the top‑level (“main”) context or the main NGINX Plus configuration file, /etc/nginx/nginx.conf:

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

  4. Reload NGINX Plus to enable the module:

    $ nginx -t && nginx -s reload