1. 程式人生 > >deny nginx頻繁訪問的IP

deny nginx頻繁訪問的IP

time=`date -d  "1 minutes ago" +%Y:%H:%M`;
echo $time;
ips=`grep $time /app/nginx/logs/u.7654.com.log | grep 200  | awk '{print $1}' | sort | uniq -c | awk '{if($1>100) print "deny "$2 ";"}'`;
echo $ips;
if [ -n "$ips" ];then
        echo $ips>>/app/nginx/conf/deny.conf;
        nginx -s reload
else
   echo "null";
fi