1、在server里边配置,对该域名的所有服务进行添加白名单,统筹配置
server { listen 443 ssl; server_name www.baidu.com; #设置长连接 keepalive_timeout 70; #白名单ip include /usr/local/nginx/Whitelist/Whitelist.conf; ……………………其他配置 } [root@localhost nginx]# cat /usr/local/nginx/Whitelist/Whitelist.conf #注释ip allow 36.113.98.246; deny all;
2、在location中配置,只对该域名下的某个服务进行添加白名单,个别配置
server { listen 443 ssl; server_name www.baidu.com; #设置长连接 keepalive_timeout 70; ……………………其他配置 #只对该域名下的portal服务限制白名单访问 location /portal { allow 36.113.98.246; deny all; ……………………其他配置 }
}