Nginx+iptables screen access to Web pages too frequent IP (anti-DDoS, malicious access, collector) _nginx

Source: Internet
Author: User
Tags iptables
The script is as follows:
Copy Code code as follows:

#!/bin/sh
Nginx_home =/data/app_1/nginx
Log_path =/data/logs
/usr/bin/tail-n50000 $log _path/access.log \
|awk ' ~/aspx/{print $2,$13} '
|grep-i-v-e "google|yahoo|baidu|msnbot| Feedsky|sogou "\
|awk ' {print $} ' |sort|uniq-c |sort-rn \
|awk ' {if ($1>150) print "Deny" $2″; "}" > $nginx _home/conf/vhosts/blockip.conf
/bin/kill-hup ' Cat $nginx _home/nginx.pid '

can also be analyzed by the Nginx log filter frequent access to IP, directly with iptables shielding this IP, you do not need to restart the nginx, and shielding effect better.

The command for a single IP is
Iptables-i input-s 124.115.0.199-j DROP

The command for the IP segment is
Iptables-i input-s 124.115.0.0/16-j DROP

The order of the entire paragraph is
Iptables-i input-s 194.42.0.0/8-j DROP

The order to seal a few paragraphs is
Iptables-i input-s 61.37.80.0/24-j DROP
Iptables-i input-s 61.37.81.0/24-j DROP

I didn't even get into the-_-!!!
Iptables-i input-p tcp–dport 80-s 124.115.0.0/24-j DROP
In the future with this only seal 80 port on the line, will not be a problem!

Iptables-i input-p tcp–dport 80-s 124.115.0.0/24-j DROP

Iptables-i input-s 61.37.81.0/24-j DROP

Solve the letter
Iptables-f
Empty
iptables-d INPUT Number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.