4EWQE 发表于 2017-11-7 10:54:11

Nginx指定IP无须通过认证

为了保证网站的安全性,我们一般都限制IP访问,但是这种方法又不灵活,使用VPN又太复杂,那么可以通过再增加一道认证来提升安全性。

需求: 指定IP直接访问,否则增加二次认证

1
2
3
4
5
6
7
8
9
10
11
12
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认证的方式

allowDeny
satisfy any不认证Basic认证
satisfy allBasic认证拒绝连接
通过satisfy any来实现IP白名单

页: [1]
查看完整版本: Nginx指定IP无须通过认证