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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

nginx限制请求之四:目录进行IP限制

發(fā)布時間:2025/7/14 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx限制请求之四:目录进行IP限制 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

相關(guān)文章:

《高可用服務(wù)設(shè)計之二:Rate limiting 限流與降級》

《nginx限制請求之一:(ngx_http_limit_conn_module)模塊》

《nginx限制請求之二:(ngx_http_limit_req_module)模塊》

《nginx限制請求之三:Nginx+Lua+Redis 對請求進行限制》

《nginx限制請求之四:目錄進行IP限制》

?

一個不錯的nginx中針對目錄進行IP限制 ,這里我以phpmyadmin目錄只能讓內(nèi)網(wǎng)IP訪問,而外網(wǎng)不能訪問的配置方法,有需要的同學(xué)可參考。

server {listen 80;server_name example.com;access_log logs/access.log main;location / {root html;index index.php index.html index.htm;}location ~ ^/phpmyadmin/ {allow 192.168.1.0/24;deny all;location ~ .*.(php|php5)?$ {root /var/mailapp/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;}}location ~ .*.(php|php5)?$ {root /opt/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;}}

nginx?phpmyadmin?針對內(nèi)網(wǎng)ip用戶開放、外網(wǎng)ip用戶關(guān)閉(在前面的配置中,location ~ ^/目錄/使用正則, 優(yōu)先級高于location /的配置,所以nginx無法對首頁進行解析)

我們也可以這樣配置

?

server {listen 80;server_name example.com;access_log logs/access.log main;location / {root html;index index.php index.html index.htm;}location ~ ^/download/ {allow 192.168.1.0/24;deny all;index index.php index.do index.html index.htm;location ~ .*.(php|php5)?$ {root /var/mailapp/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;}}location ~ .*.(php|php5)?$ {root /opt/nginx/html;astcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;}

限制指定的連接只允許 某個指定的IP 能行訪問

總結(jié)

以上是生活随笔為你收集整理的nginx限制请求之四:目录进行IP限制的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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