99热,在线视频免费精品,亚洲综合视频在线观看,久久免费高清视频,九九热视频在线播放,日韩精品在线播放视频,99久久精品免费视频

龍巖易富通網(wǎng)絡(luò )科技有限公司

龍巖小程序開(kāi)發(fā),龍巖分銷(xiāo)系統

debian系統寶塔nginx配置geoip2屏蔽國家訪(fǎng)問(wèn)

2025.10.31 | 20閱讀 | 0條評論 | 通用代碼

一:安裝geoip2依賴(lài)擴展

sudo apt install libmaxminddb-dev -y


二:下載ngx_http_geoip2_module

git clone https://github.com/leev/ngx_http_geoip2_module.git


三:在寶塔面板里邊安裝nginx的時(shí)候選擇編譯安裝,并手動(dòng)增加擴展,安裝時(shí)候點(diǎn)擊啟用

模塊名稱(chēng) ngx_http_geoip2_module

模塊說(shuō)明 禁用國家ip

模塊參數 --add-module=/path/to/ngx_http_geoip2_module

等待安裝后輸入 nginx -V 查看是否安裝成功


四:在寶塔中安裝geoip

配置nginx

在nginx配置文件中,http段加入以下代碼。以寶塔安裝的nginx為例,打開(kāi)/www/server /nginx/conf/nginx.conf文件,

在http中添加


geoip2 /usr/share/GeoIP/Country.mmdb {

    $geoip2_data_country_code country iso_code;

}

map $geoip2_data_country_code $allowed_country {

    default yes;

    CN yes;

    JP no;

    DE no;

}


在站點(diǎn)配置文件添加:

if ($allowed_country = no) {

    return 403;

}


贊 (

發(fā)表評論

尚志市| 酉阳| 泉州市| 和平区| 林口县| 砚山县| 安溪县| 闵行区| 怀集县| 山西省| 望谟县| 馆陶县| 荥经县| 宁晋县| 河南省| 青岛市| 新建县| 合江县| 金阳县| 云林县| 开化县| 苏尼特左旗| 霞浦县| 乌兰浩特市| 乌海市| 崇仁县| 三门县| 莱州市| 桑植县| 威海市| 治多县| 沙河市| 铜鼓县| 陕西省| 台北市| 鲁山县| 韶关市| 广饶县| 天等县| 舒城县| 乐山市|