• Your shopping cart is empty!

IP2Location Nginx Module

This is an IP2Location Nginx Module that enables the user to identify the country code and country name by IP address. In general, it is faster, easier and more accurate than reverse DNS lookups.

Installation
  1. Download IP2location C library from here.
  2. Download and decompress this Nginx module package.
  3. Change the path to IP2Location library in "ngx_http_ip2location_module.c".
  4. Re-compile Nginx from source to include this module. Add the below directive into the compile of Nginx:
    ./configure --add-module=/absolute/path/to/nginx-ip2location-8.0.0
    make
    make install
  5. Edit your Nginx config file to point the correct path of IP2Location database file:
    ip2location_database /absolute/path/to/IP2LOCATION-DB1.BIN;
Sample Codes

Block visitors from China:

if ( $ip2location_country_code = "CN" ) {
	return 403;
}

Redirect visitors from Canada, United States, and Mexico to new page:

if ( $ip2location_country_code ~* "CA|US|MX" ) {
	rewrite ^ http://example.com/newpage.html permanent;
}
Community Modules
  • ngx-ip2location

    This is a IP2Location Nginx Module that enables the user to identify the country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, area code and weather by IP address.

Sample IP2Location Databases (BIN)
Sample Packages IPv4 IPV6
IP2Location DB1 Sample BIN File Download (692.11 kB) Download (350.84 kB)
IP2Location DB2 Sample BIN File Download (36.88 MB) Download (378.66 kB)
IP2Location DB3 Sample BIN File Download (19.16 MB) Download (363.65 kB)
IP2Location DB4 Sample BIN File Download (52.88 MB) Download (388.27 kB)
IP2Location DB5 Sample BIN File Download (29.12 MB) Download (370.18 kB)
IP2Location DB6 Sample BIN File Download (62.43 MB) Download (393.44 kB)
IP2Location DB7 Sample BIN File Download (58.77 MB) Download (398.64 kB)
IP2Location DB8 Sample BIN File Download (68.55 MB) Download (403.55 kB)
IP2Location DB9 Sample BIN File Download (33.54 MB) Download (373.45 kB)
IP2Location DB10 Sample BIN File Download (73.78 MB) Download (408.65 kB)
IP2Location DB11 Sample BIN File Download (34.20 MB) Download (374.17 kB)
IP2Location DB12 Sample BIN File Download (74.42 MB) Download (409.59 kB)
IP2Location DB13 Sample BIN File Download (32.84 MB) Download (371.65 kB)
IP2Location DB14 Sample BIN File Download (75.70 MB) Download (410.29 kB)
IP2Location DB15 Sample BIN File Download (37.06 MB) Download (378.07 kB)
IP2Location DB16 Sample BIN File Download (80.23 MB) Download (415.93 kB)
IP2Location DB17 Sample BIN File Download (39.59 MB) Download (380.09 kB)
IP2Location DB18 Sample BIN File Download (87.03 MB) Download (425.95 kB)
IP2Location DB19 Sample BIN File Download (71.22 MB) Download (404.88 kB)
IP2Location DB20 Sample BIN File Download (89.37 MB) Download (427.07 kB)
IP2Location DB21 Sample BIN File Download (40.38 MB) Download (380.72 kB)
IP2Location DB22 Sample BIN File Download (93.23 MB) Download (430.11 kB)
IP2Location DB23 Sample BIN File Download (71.61 MB) Download (405.90 kB)
IP2Location DB24 Sample BIN File Download (94.28 MB) Download (431.79 kB)