• Your shopping cart is empty!

IP2Location IP Geolocation Nginx Module

This is an IP2Location IP Geolocation 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-x.x.x
    make
    make install
  5. Edit your Nginx config file (nginx.conf), add the following lines under `http` context:
    http {
    ip2location on;
    ip2location_database /absolute/path/to/DB1.BIN;
    ip2location_reverse_proxy on;
    ip2location_access_type shared_memory;
    }
Sample Codes

Block visitors from China:

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

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

if ( $ip2location_country_short ~* "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.

Articles & Tutorials

You can always refer to our blog for the articles and tutorials about IP2Location NginX module.

Sample IP2Location Databases (BIN)
Sample Packages IPv4 IPV6
IP2Location DB1 Sample BIN File Download (792.50 kB) Download (346.40 kB)
IP2Location DB2 Sample BIN File Download (35.01 MB) Download (367.38 kB)
IP2Location DB3 Sample BIN File Download (20.10 MB) Download (360.08 kB)
IP2Location DB4 Sample BIN File Download (52.33 MB) Download (379.60 kB)
IP2Location DB5 Sample BIN File Download (30.29 MB) Download (366.64 kB)
IP2Location DB6 Sample BIN File Download (61.93 MB) Download (384.79 kB)
IP2Location DB7 Sample BIN File Download (59.11 MB) Download (389.13 kB)
IP2Location DB8 Sample BIN File Download (68.91 MB) Download (394.91 kB)
IP2Location DB9 Sample BIN File Download (34.88 MB) Download (370.93 kB)
IP2Location DB10 Sample BIN File Download (74.48 MB) Download (400.20 kB)
IP2Location DB11 Sample BIN File Download (35.56 MB) Download (372.09 kB)
IP2Location DB12 Sample BIN File Download (75.07 MB) Download (401.28 kB)
IP2Location DB13 Sample BIN File Download (34.14 MB) Download (368.28 kB)
IP2Location DB14 Sample BIN File Download (76.38 MB) Download (401.98 kB)
IP2Location DB15 Sample BIN File Download (38.61 MB) Download (376.77 kB)
IP2Location DB16 Sample BIN File Download (81.03 MB) Download (408.29 kB)
IP2Location DB17 Sample BIN File Download (41.13 MB) Download (378.70 kB)
IP2Location DB18 Sample BIN File Download (88.02 MB) Download (419.83 kB)
IP2Location DB19 Sample BIN File Download (71.89 MB) Download (396.10 kB)
IP2Location DB20 Sample BIN File Download (90.42 MB) Download (421.01 kB)
IP2Location DB21 Sample BIN File Download (41.99 MB) Download (379.75 kB)
IP2Location DB22 Sample BIN File Download (94.36 MB) Download (424.83 kB)
IP2Location DB23 Sample BIN File Download (72.33 MB) Download (397.07 kB)
IP2Location DB24 Sample BIN File Download (95.54 MB) Download (426.11 kB)