nginx封锁IP,并且定时取消

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash
max=5
confdir=/usr/local/nginx/conf/blockip.conf
logdir=/usr/local/nginx/logs/access.log
echo "">$confdir
cat $logdir|awk '{print $1}'|sort|uniq -c|sort -n|while read line
do
a=(`echo $line`)
if [ $a -ge $max ]
then
 echo "deny ${a[1]};">>$confdir
fi
done
service nginx reload
at now+2 minutes -f /root/unblockip.sh