Get Started With IP2Proxy Nginx Module

Dependencies

This module requires IP2Proxy BIN database to function. You may download the BIN database at


Installation

  1. Download IP2Proxy C library from here.

  2. Compile and install IP2Proxy C library.

  3. Download IP2Proxy module and decompress the package.

    wget https://github.com/ip2location/ip2proxy-nginx/archive/master.zip
    unzip master.zip
    rm master.zip
  4. Download the latest Nginx source code from here.

    wget https://nginx.org/download/nginx-x.y.z.tar.gz
    
  5. Decompress and go into Nginx source directory.

    tar xvfz nginx-x.y.z.tar.gz
    cd nginx-x.y.z
    
  6. Re-compile Nginx from source to include this module.

    Static Module

    ./configure --add-module=/absolute/path/to/nginx-ip2proxy-master
    make
    make install

    Dynamic Module

    ./configure --add-dynamic-module=/absolute/path/to/nginx-ip2proxy-master
    make
    make install
  7. 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.66 kB)
IP2Proxy PX2 Download (406.53 kB)
IP2Proxy PX3 Download (435.82 kB)
IP2Proxy PX4 Download (471.49 kB)
IP2Proxy PX5 Download (491.37 kB)
IP2Proxy PX6 Download (493.92 kB)
IP2Proxy PX7 Download (534.57 kB)
IP2Proxy PX8 Download (540.70 kB)
IP2Proxy PX9 Download (541.56 kB)
IP2Proxy PX10 Download (677.91 kB)
IP2Proxy PX11 Download (684.40 kB)
IP2Proxy PX12 Download (687.12 kB)

Articles & Tutorials