日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

nginx之Geoip读取地域信息模块

發(fā)布時間:2024/9/3 编程问答 62 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx之Geoip读取地域信息模块 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1 geoip_module模塊

基于IP地址匹配MaxMind GeolP二進制文件,讀取IP所在地域信息。

yum install nginx-module-geoip

geoip2已經(jīng)有了,安裝另尋

2、http_geoip_module使用

一、區(qū)別國內(nèi)外作HTTP訪問規(guī)則

二、區(qū)別國內(nèi)城市地域作HTTP訪問規(guī)則

用到的ip數(shù)據(jù)庫

鏈接:https://pan.baidu.com/s/1KcFhouFhP7jQOEZaZutMtw? 提取碼:okjp

vim nginx.conf load_module modules/ngx_http_geoip_module.so; #導入模塊 load_module modules/ngx_stream_geoip_module.so; ? user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events {worker_connections 1024; } http {log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;include /etc/nginx/mime.types;default_type application/octet-stream; ?include /etc/nginx/conf.d/cp5/*.conf; } ?cat conf.d/cp5/test_geoip.conf geoip_country /etc/nginx/geoip/GeoIP.dat; # geoip_city /etc/nginx/geoip/GeoLiteCity.dat;# geoip_country /tmp/geoip/GeoLite2-Country/GeoLite2-Country.mmdb; # geoip_city /tmp/geoip/GeoLite2-City/GeoLite2-City.mmdb;server {listen 80;server_name web01.fadewalk.com;?location / {if ($geoip_country_code != CN) {return 403;}root /usr/share/nginx/html;index index.html index.htm;}location /myip {default_type text/plain;return 200 "$remote_addr $geoip_country_name $geoip_country_code $geoip_city";}}

測試

總結(jié)

以上是生活随笔為你收集整理的nginx之Geoip读取地域信息模块的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。