浏览模式: 普通 | 列表
7月, 2017 | 1
通过分析nginx的日志来过滤出访问过于频繁的IP地址,然后添加到nginx的blockip.conf,并重启nginx.
#!/bin/sh
nginx_home = /Data/app_1/nginx
log_path = /Data/logs
/usr/bin/tail -n50000 $log_path/access.log \
|awk ‘$8 ~/aspx/{print $2,$13}' \
|grep -i -v -E “google|yahoo|baidu|msnbot|FeedSky|sogou” \
|awk ‘{print $1}'|sort|uniq -c |sort -rn \
|awk ‘{if($1>150)print “deny “$2″;”}'> $nginx_home/conf/vhosts/blockip.conf
/bin/kill
...

阅读全文…
1