设为首页收藏本站

简体中文 繁體中文 English 日本語 Deutsch 한국 사람 بالعربية TÜRKÇE português คนไทย french

搜索
热搜: 活动 交友 discuz

在阿军的LNMP上添加防CC,只能防轻量CC [复制链接]
查看:218 | 回复:31

446

主题

7820

回帖

1万

积分

论坛元老

积分
17044
发表于 2013-5-4 14:15:13 | 显示全部楼层 |阅读模式
本帖最后由 lazyzhu 于 2013-5-4 19:23 编辑

由我blog文章改编而来
http://lazyzhu.com/Nginx/LNMP-compile-nginx-redis-module-to-build-redis-cache.html
这是最简单最没技术含量的,只要简单加两行配置就行

其实可以还有更强大的功能:
将CC攻击的IP自动添加进机房路由器防火墙(有条件的话)
将CC攻击的IP自动添加进iptables防火墙
将CC攻击的IP封禁自定义时间,过后自动释放
将被CC攻击的页面进行缓存,降低后端资源
将CC攻击的IP转向自定义网页,或随机网页
......


1. 停止LNMP服务
"



2. 备份LNMP配置
"


3.重编译nginx + limit_req2_nginx_module

"
"
"


4. 修改Nginx配置

log_format  lazyzhu.com  '$remote_addr - $remote_user [$time_local] $request '
             '$status $body_bytes_sent $http_referer '
             '$http_user_agent $http_x_forwarded_for';

limit_req2_zone $request_uri zone=lazyzhu.com.one:2m rate=5r/s;
limit_req2_zone $binary_remote_addr zone=lazyzhu.com.two:2m rate=30r/s;

server {
    listen       80;
    server_name  lazyzhu.com;
    root  /home/wwwroot/lazyzhu.com;
    location / {
        index index.html index.htm index.php default.html default.htm default.php;
    }
    include none.conf;
    ## folder disable limit
    location ^~ /(wp-admin|admin)/ {
        limit_req2  off;
        try_files     $uri =404;
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        include       fcgi.conf;
    }
    ## file disable limit
    location ~ .*(admin|p)\.(php|php5)?$ {
        limit_req2  off;
        try_files     $uri =404;
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        include       fcgi.conf;
    }
    location ~ .*\.(php|php5)?$ {
        
limit_req2 zone=lazyzhu.com.one forbid_action=@444 nodelay;

        
limit_req2 zone=lazyzhu.com.two forbid_action=@444 nodelay;

        try_files     $uri =404;
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        include       fcgi.conf;
    }
    location @444 {
        return 444;
    }
    location ~ .*\.(js|css)?$ {
        expires  12h;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires  30d;
    }
    location /status {
        stub_status  on;
        access_log  off;
    }
    access_log  /home/wwwlogs/lazyzhu.com.log  lazyzhu.com;
}


5. 启动LNMP服务
"

362

主题

1034

回帖

3210

积分

论坛元老

积分
3210
发表于 2013-5-4 14:16:22 | 显示全部楼层
沙发。。

327

主题

4850

回帖

1万

积分

论坛元老

积分
10735
发表于 2013-5-4 14:17:55 | 显示全部楼层
板凳。。

137

主题

1722

回帖

3887

积分

论坛元老

积分
3887
发表于 2013-5-4 14:19:09 | 显示全部楼层
└(^o^)┘

484

主题

3883

回帖

9276

积分

论坛元老

积分
9276
发表于 2013-5-4 14:21:19 | 显示全部楼层
哎有人CC ing

60

主题

1437

回帖

3124

积分

论坛元老

积分
3124
发表于 2013-5-4 14:53:18 | 显示全部楼层
支持下技术文章

60

主题

1437

回帖

3124

积分

论坛元老

积分
3124
发表于 2013-5-4 14:54:48 | 显示全部楼层
支持下技术文章

127

主题

1445

回帖

3349

积分

论坛元老

积分
3349
发表于 2013-5-4 15:05:43 | 显示全部楼层
cc来了

158

主题

1408

回帖

3350

积分

论坛元老

积分
3350
发表于 2013-5-4 15:06:31 | 显示全部楼层


尼玛,我提出的 return 444 我删除了文章又变成你的了。

0

主题

1

回帖

4

积分

新手上路

积分
4
发表于 2013-5-4 15:07:08 | 显示全部楼层
支持
skwinx 发表于 2013-5-4 15:06



尼玛,我提出的 return 444 我删除了文章又变成你的了。




见过不要脸的,没见过像你这样不要脸的
http://www.hostloc.com/forum.php ... 089&pid=2607521
从nginx加入444一直在用了
您需要登录后才可以回帖 登录 | 立即注册

论坛客服/商务合作/投诉举报:2171544 (QQ)
落伍者创建于2001/03/14,本站内容均为会员发表,并不代表落伍立场!
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论!
落伍官方微信:2030286 邮箱:(djfsys@gmail.com|tech@im286.com)
© 2001-2014

浙公网安备 33060302000191号

浙ICP备11034705号 BBS专项电子公告通信管[2010]226号

  落伍法律顾问: ITlaw-庄毅雄

Archiver|手机版|Discuz! X

GMT+8, 2026-1-24 10:36 , Processed in 0.019855 second(s), 6 queries , Gzip On, Redis On.

返回顶部