Shell practice: Analyze nginx logs at regular intervals, and block users using webscan on this site from 01 to analyze nginx logs at regular intervals, and will block the use of webscan for this site 02 when viewing nginx logs found 03 atible; MSIE 6.0; Windows NT 5.0 ;. net clr 1.1.4322) "042108181.55.30--[20/Jul/2013: 19: 55: 57 + 0400]" GET/article/show/14 /? Classid = 2-% 28-9999995% 29-9999995-0-0-0 HTTP/1.1 "200 5285" http://scpman.com: 80/article/show/14 /? Classid = 2-% 28-9999995% 29-9999995-0-0-0 "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; WebscanSpider) "05220.181.55.29--[20/Jul/2013: 20: 06: 05 + 0400]" GET/web-console/HTTP/1.1 "404 225" http://scpman.com: 80/web-console/"" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; WebscanSpider) "06: 07 # cat/usr/shell_work/iptab_nginx.sh08 #! /Bin/bash09 # code by scpman10 # ban the webscan users on this site, and there are fewer users .. 11for ip in 'cat/usr/local/nginx/logs/access. log | grep 'webscanspider '| awk' {print $1} '| sort-u'12do13/sbin/iptables-I INPUT-s $ ip-p TCP -- dport 80-j DROP14done15 # add it to the timer, come back once every 10 minutes 16 */10 */usr/shell_work/iptab_nginx.sh17Chain INPUT (policy ACCEPT) 18num target prot opt source destination 191 DROP tcp -- 220.181.55.30 0.0.0.0/0 tcp dpt: 80202 DROP tcp -- 220.181.55.29 0.0.0.0/0 tcp dpt: 8021