Home  >  Article  >  Operation and Maintenance  >  What is the use of nginx’s GeoIP?

What is the use of nginx’s GeoIP?

(*-*)浩
(*-*)浩Original
2019-12-21 15:42:024247browse

What is the use of nginx’s GeoIP?

The GeoIP module in Nginx can block requests for specified IPs, but it is not compiled by default. After opening it, we only need to download another IP rule and configure it in the Nginx server GeoIP module to intercept specified country IP.                                                                                                                                                                                                                                                       ​ I took the time to research this information. The best method found so far is to use Nginx's GeoIP module to achieve region identification. Then configure the ISO name of the relevant country and prohibit access. Record the relevant process. Compile the GeoIP component

The free version of the database provided by maxmind can already meet the needs. Before using the database, you need to compile the GeoIP component first:

wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.8.tar.gz
./configure
make
make install
Download IP library

Download the IP packet from maxmind and unzip it. This is the country’s ip data packet:

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
This is the city’s ip data packet:

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

After executing the above command, you will get GeoIP.dat and GeoLiteCity .dat files. Copy these two files to Nginx's conf directory.

The above is the detailed content of What is the use of nginx’s GeoIP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to optimize nginxNext article:How to optimize nginx