首頁  >  文章  >  運維  >  nginx的GeoIP有什麼用

nginx的GeoIP有什麼用

(*-*)浩
(*-*)浩原創
2019-12-21 15:42:024247瀏覽

nginx的GeoIP有什麼用

Nginx中自帶GeoIP模組可以屏蔽指定IP的請求,只不過預設沒有被編譯,打開以後我們只要再下載一個IP規則就行,Nginx伺服器中配置GeoIP模組來攔截指定國家IP。                                                            中上要求中要求使用: 。花時間研究了一下這方面的資料。目前找到的最佳方法是使用 Nginx 的 GeoIP 模組來實現地區的識別。然後配置相關國家的 ISO 名稱,禁止訪問即可。記錄一下相關過程。 編譯GeoIP 元件

maxmind 提供的免費版資料庫已經可以滿足需求,在使用資料庫前,需要先編譯GeoIP 元件:

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

從maxmind 下載IP 封包並解壓縮。這是國家的ip封包:

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
這個是城市的ip封包:

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

執行完上面的指令後,會得到GeoIP.dat 和GeoLiteCity .dat 檔。將這兩個檔案複製到 Nginx 的 conf 目錄。

以上是nginx的GeoIP有什麼用的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn