在http 模块 增加

geo $remote_addr $ip_whitelist{
default 0;
include white_ip.conf;
}

 

在location 模块 增加 (注意if 和($ip)之间有空格)

if  ($ip_whitelist = 0){
return 403;
}

在conf  同级目录 添加white_ip.conf 文件

将白名单ip添加进去 如:183.157.83.10  1;

重启nginx 即可

如果white_ip.conf  没有对应的ip 请求服务器将看到 403 forbidden

 

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2021-12-04
  • 2021-11-20
猜你喜欢
  • 2021-10-18
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案