全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
12
返回列表 发新帖
楼主: kirkcong

[nginx] 遭遇CC攻击,多种办法,求技术讨论

[复制链接]
发表于 2010-10-8 11:51:38 | 显示全部楼层
从防火墙上入手,不要凭什么nginx,更不能凭dz功能,

抗cc要在防火墙那一级才有效。弄个脚本,把连接过多的,频繁刷一个面的过滤出来,K 掉就可以OK了

评分

参与人数 1威望 +7 收起 理由
狒狒 + 7

查看全部评分

发表于 2010-10-8 12:02:44 | 显示全部楼层
ddos-deflate完全可以做到的。

比如:你可以设置每分钟同一IP访问的线程数为30个,超过了会触发iptables自动ban掉一段时间。
发表于 2010-10-8 12:04:01 | 显示全部楼层
个人经验认为:
小型的比较愚蠢的CC, ddos-deflate可以解决

大型的, 成千上w的同时CC的, ddos-deflate解决不了

写个脚本监视LOG比较好
发表于 2010-10-8 12:43:00 | 显示全部楼层
你这还不算牛的

某论坛最近几天。天天被十几台XXOO。。一封IP他们就换

还有我的某网站几乎天天被KO
发表于 2010-11-2 08:06:04 | 显示全部楼层
你去装个CSF,然后用这个脚本(前提你是LNMP)

#!/bin/bash

#Collecting list of ip addresses connected to port 80

netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1 > /root/iplist

#Limit the no of connections
LIMIT=15;

for ip in `cat /root/iplist |awk '{print $2}'`;do

        if [ `grep $ip /root/iplist | awk '{print $1}'` -gt $LIMIT ]
        then
                echo "15 connection from $ip... `grep $ip /root/iplist | awk '{print $1}'` number of connections... Blocking $ip";

                #Blocking the ip ...

                CHECK_IF_LOCALIP=0;
                /sbin/ifconfig | grep $ip > /dev/null;
                if [ $? -ne $CHECK_IF_LOCALIP ]
                then {
                        FLAG=0;
                        grep $ip /etc/csf/csf.deny > /dev/null;
                        if [ $? -ne $FLAG ]
                        then
                                iptables -I INPUT -s $ip -j DROP;
                                echo "deny $ip;" >> /usr/local/nginx/conf/vhost/block.conf;
                                /usr/sbin/csf -d $ip;
                                ~/lnmp reload;
                        else
                                echo " Ipaddress $ip is already blocked ";
                        fi
                }
                else
                        echo " Sorry, the ip $ip cannot be blocked since this is a local ip of the server ";
                fi
        fi
done
发表于 2010-11-2 08:45:21 | 显示全部楼层
  楼上有高人
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-16 16:49 , Processed in 0.063892 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表