Get Started With IP2Proxy Nginx Module
Dependencies
This module requires IP2Proxy BIN database to function. You may download the BIN database at
IP2Proxy LITE BIN Data (Free): https://lite.ip2location.com
IP2Proxy Commercial BIN Data (Comprehensive): https://www.ip2location.com
Installation
Download IP2Proxy C library from here.
Compile and install IP2Proxy C library.
-
Download IP2Proxy module and decompress the package.
wget https://github.com/ip2location/ip2proxy-nginx/archive/master.zip unzip master.zip rm master.zip -
Download the latest Nginx source code from here.
wget https://nginx.org/download/nginx-x.y.z.tar.gz -
Decompress and go into Nginx source directory.
tar xvfz nginx-x.y.z.tar.gz cd nginx-x.y.z -
Re-compile Nginx from source to include this module.
Static Module
./configure --add-module=/absolute/path/to/nginx-ip2proxy-master make make installDynamic Module
./configure --add-dynamic-module=/absolute/path/to/nginx-ip2proxy-master make make install -
Edit your Nginx config file (nginx.conf), add the following lines under `http` context:
http { ... ip2proxy_database /usr/share/ip2location/PX3.BIN; ip2proxy_proxy_recursive on; ip2proxy_proxy 192.168.1.0/24; }
Sample Codes
Block proxy IP
if ( $ip2proxy_is_proxy = '1' ) {
return 444;
}
Block spammers
if ( $ip2proxy_threat = 'SPAM' ) {
return 444;
}
IP2Proxy Sample Database (BIN)
| Sample Packages - BIN File | IPv4 + IPv6 |
|---|---|
| IP2Proxy PX1 | Download (391.15 kB) |
| IP2Proxy PX2 | Download (406.80 kB) |
| IP2Proxy PX3 | Download (436.24 kB) |
| IP2Proxy PX4 | Download (471.65 kB) |
| IP2Proxy PX5 | Download (491.98 kB) |
| IP2Proxy PX6 | Download (494.79 kB) |
| IP2Proxy PX7 | Download (536.04 kB) |
| IP2Proxy PX8 | Download (542.17 kB) |
| IP2Proxy PX9 | Download (542.01 kB) |
| IP2Proxy PX10 | Download (673.87 kB) |
| IP2Proxy PX11 | Download (680.81 kB) |
| IP2Proxy PX12 | Download (685.90 kB) |