pyzen / ngx_http_geoip2_module

Nginx GeoIP2 module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Description

ngx_http_geoip2_module - creates variables with values from the maxmind geoip2 databases based on the client IP (supports both IPv4 and IPv6)

Installing

First install libmaxminddb as described in its README.md file.

Compile nginx:

./configure --add-module=/path/to/ngx_http_geoip2_module
make 
make install

Download Maxmind GeoLite2 Database (optional)

The free GeoLite2 databases are available from Maxminds website

GeoLite2 City GeoLite2 Country

Example Usage:

http {
    ...
    geoip2 /etc/maxmind-country.mmdb {
        $geoip2_data_country_code default=US country iso_code;
        $geoip2_data_country_name country names en;
    }

    geoip2 /etc/maxmind-city.mmdb {
        $geoip2_data_city_name default=London city names en;
    }
    ....
}

About

Nginx GeoIP2 module

License:BSD 2-Clause "Simplified" License


Languages

Language:C 100.0%