Nginx訪問控制

2021-09-11 05:11:37 字數 422 閱讀 5518

#配置nginx,禁止訪問指定目錄下的指定程式

location ~ ^/images/.*.(php|php5|sh|pl|py)$

#nginx下配置禁止訪問*.txt和*.doc檔案

location ~* \.(txt|doc)$

}location ~* \.(txt|doc)$

#禁止訪問單個目錄

location ~ ^/static

#禁止訪問多個目錄

location ~ ^/(static|js)

#nginx限制http請求方法

$request_method 請求方法

if ($request_method !~ ^(get|head|post)$)

Nginx訪問控制

基於ip的訪問控制 http access module 基於使用者的信任登入 http auth basic module 語法1 允許那些ip可以訪問 語法2 不允許那些ip訪問 1.配置不允許指定ip訪問,其他ip都可以訪問 location admin.html測試一下 使用其他ip訪問,訪...

Nginx服務訪問控制

在企業中有時候需要為 進行進行許可權控制。配置示例 location auth basic引數 設定認證提示資訊 語法 auth basic 字串 off 預設值是off。auth basic user file引數 設定密碼檔案位置 語法 auth basic user file 檔案 使用位置 ...

Nginx模組 訪問控制

環境 centos7 nginx 1.16.0 nginx的訪問控制實現中存在如下兩種方式 基於ip的訪問控制 http access module 基於使用者的信任登入 http auth basic module 配置語法 與allow相反,即不允許 實踐 對配置檔案進行修改,儲存重啟nginx...