When set the following variables are available: It can be used to determine the visitor’s country from the IP address of the client. This allows you to get the country corresponding to the given IP. dat file that associates IP addresses with country geolocation information. This directive specifies the full path to the Geo IP database. This means that Geo IP support is enabled.įastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code įastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name Directives geoip_country Syntax: You can check if your installed version of Nginx supports Geo IP with nginx -V.
#Maxmind nginx install#
aptitude install libgeoip-devįor systems where there’s not a packaged version of the library you’ll have to compile it from source: wget įollow the install instructions provided there.Ĭompile Nginx enabling Geo IP support. In Debian they’re in the package libgeoip-dev. To compile Nginx you’ll need the library development files. You’ll need to download the city database from Maxmind site: wget Note that this is only the country database. The FreeBSD port provides the GeoLite country database located at /usr/local/share/GeoIP/GeoIP.dat For example in FreeBSD the port is called “GeoIP”. Install a port providing the database.For example in Debian the package is called geoip-database. Install a package providing the database.This module needs the geo databases and the library to read from the database. This module appeared in nginx version 0.7.63 and 0.8.6. This module creates ngx_http_geoip_module variables based on the IP-address of the client matched against the MaxMind GeoIP binary files.