Page Discussion History


Revision as of 17:54, 22 September 2010 by Kolbyjack (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



This module has been replaced by the official NginxHttpGeoIPModule since Nginx 0.7.63/0.8.6.

Please use this module only for Nginx 0.7.62 or earlier.

The Nginx GeoIP module is based on the original Geo module, the difference being that it is not being controlled by a piece of config, but makes use of the MaxMind GeoIP binary API natively. It provides for fast lookups from both the binary GeoLite Country and GeoIP Country databases.

One of the advantages to use the binary databases and API is getting automated updates from MaxMind through the geoipupdate utility. This is also the reason why SPIL GAMES wrote this module.

Example usage:

geoip_country_file /absolute/path/to/GeoIP.dat;
location /geoip/ {
  rewrite .* /?country=$geoip_country_code;



syntax: geoip_country_file path

default: n/a

context: http

Enables resolving of $geoip_country_* variables documented below.


For now the following variables are supported:

$geoip_country_code, this variable contains the alpha-2 country code as resolved by the GeoIP country API.

$geoip_country_code3, this variable contains the alpha-3 country code as resolved by the GeoIP country API.

$geoip_country_name, this variable contains the country name as resolved by the GeoIP country API.


To install, download the source tarball ( File:Nginx-geoip-0.2.tar.gz ), expand it, and then compile nginx with the following option:

. --add-module=/path/to/nginx-geoip-0.2

Please make sure to have the GeoIP C API installed and in your system library paths.


  • Allow control of memory caching options (fixed to GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE for now)
  • Add support for GeoIP City databases?


Please report bugs to matthijs AT SPAMFREE spilgames DOT com.