需求: 指定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白名单