HttpGuard(专注防cc攻击,更强大的防御能力)

2017年7月19日 31341点热度 2人点赞 4条评论

什么是HttpGuard


HttpGuard是基于openresty,以lua脚本语言开发的防cc攻击软件。而openresty是集成了高性能web服务器Nginx,以及一系列的Nginx模块,这其中最重要的,也是我们主要用到的nginx lua模块。HttpGuard基于nginx lua开发,继承了nginx高并发,高性能的特点,可以以非常小的性能损耗来防范大规模的cc攻击。
下面介绍HttpGuard防cc的一些特性。

  • 限制访客在一定时间内的请求次数
  • 向访客发送302转向响应头来识别是否是恶意用户,并阻止其再次访问
  • 向访客发送带有跳转功能的js代码来识别是否是恶意用户,并阻止其再次访问
  • 支持向访客发送带有验证码的页面,来进一步识别,以免误伤
  • 支持直接断开恶意访客的连接
  • 支持结合iptables来阻止恶意访客再次连接
  • 支持白名单功能
  • 支持根据统计特定端口的连接数来自动开启或关闭防cc模式

github项目地址:https://github.com/centos-bz/HttpGuard
联系作者: admin#centos.bz

开始部署HttpGuard

一、安装openresty或者nginx lua


在安装HttpGuard之前,需要先安装openresty或者nginx lua,有三种方法:

二、安装HttpGuard

假设我们把HttpGuard安装到/data/www/waf/,当然你可以选择安装在任意目录,nginx运行的用户为www。
cd /data/www
wget --no-check-certificate https://github.com/centos-bz/HttpGuard/archive/master.zip
unzip master.zip
mv HttpGuard-master waf
chown www waf/logs

三、生成验证码图片(可选)


为了支持验证码识别用户,我们需要先生成验证码图片。生成验证码图片需要系统安装有php,以及php-gd模块。

以命令行执行getImg.php文件

cd /data/www/waf/captcha/
/usr/local/php/bin/php getImg.php

大概要生成一万个图片,可能需要花几分钟的时间。


四、修改nginx.conf配置文件

正文内容

向http区块输入如下代码:

lua_package_path "/data/www/waf/?.lua";
lua_shared_dict guard_dict 100m;
lua_shared_dict dict_captcha 70m;
init_by_lua_file '/data/www/waf/init.lua';
access_by_lua_file '/data/www/waf/runtime.lua';
lua_max_running_timers 1;

记得要修改相关的路径。

五、配置HttpGuard


HttpGuard全部的配置项都在config.lua文件中,请根据以下文章修改配置文件。

https://vv1234.cn/archives/245.html

Gcod

人生若只如初见,何事秋风悲画扇

文章评论

  • cops

    Thanks a lot for sharing this with all of us you actually
    understand what you're speaking approximately! Bookmarked.
    Please also discuss with my website =). We will have a link change contract between us

    2018年8月11日
  • home loans login

    va loan limits va home loan rates 30 year fixed va loans for disabled veterans va loan calculator mortgage calculator

    2018年6月18日
  • angelina

    angelina

    2017年7月26日
  • 姬长信

    有人攻击?

    2017年7月20日