跳至主要內容

Nginx封禁恶意IP

xw小于 1 分钟NginxNginx

使用

  • 所有网站屏蔽,把include xxx; 放到http {}语句块。
  • 单独网站屏蔽,把include xxx; 放到网址对应的在server{}语句块
http{
    # ....
    include blacklist.conf;
}
location / {
                proxy_pass http://lbs;
                proxy_redirect default;
}

blacklist.conf内容如下:

deny 127.0.0.1;

效果如下:

自动封禁

  • 编写shell脚本,AWK统计access.log,记录每秒访问超过60次的ip,然后配合nginx或者iptables进行封禁,crontab定时执行