Nginx指定IP無須通過認證
阿新 • • 發佈:2017-11-07
nginx 認證
為了保證網站的安全性,我們一般都限制IP訪問,但是這種方法又不靈活,使用VPN又太復雜,那麽可以通過再增加一道認證來提升安全性。
需求: 指定IP直接訪問,否則增加二次認證
server { listen 0.0.0.0:80; server_name location ~ / { satisfy any; allow 192.168.1.0/24; deny all; auth_basic "Account Authentication"; auth_basic_user_file passwd; root /var/www/html; index index.html; }
註意裏面的
satisfy any|all 部分地址Basic認證的方式
allow | Deny | |
satisfy any | 不認證 | Basic認證 |
satisfy all | Basic認證 | 拒絕連接 |
通過satisfy any來實現IP白名單
本文出自 “楓林晚” 博客,請務必保留此出處http://fengwan.blog.51cto.com/508652/1979267
Nginx指定IP無須通過認證