温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nginx_lua_waf安装测试

发布时间:2020-07-18 21:59:04 来源:网络 阅读:1428 作者:Tar0 栏目:安全技术


ngx_lua_waf是一个基于lua-nginx-module(openresty)的web应用防火墙,对于中小企业或不愿购置硬件防火墙的企业的首选,能有效保证网站的安全性。

源码:https://github.com/loveshell/ngx_lua_waf


0x1  安装部署

系统版本:Centos7 x86_64


安装依赖包

yum install -y readline-devel pcre-devel openssl-devel


1、openresty的安装配置

cd /usr/local/src


wget https://openresty.org/download/openresty-1.9.15.1.tar.gz

tar -zxvf openresty-1.9.15.1.tar.gz


cd openresty-1.9.15.1


./configure --prefix=/usr/local/openresty-1.9.15.1 --with-luajit --with-http_stub_status_module --with-pcre --with-pcre-jit


gmake && gmake install


ln -s /usr/local/openresty-1.9.15.1/ /usr/local/openresty


测试启动nginx

/usr/local/openresty/nginx/sbin/nginx -t


成功启动nginx显示如下

nginx: the configuration file /usr/local/openresty-1.9.15.1/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/openresty-1.9.15.1/nginx/conf/nginx.conf test is successful


启动nginx

/usr/local/openresty/nginx/sbin/nginx


2、配置nginx_lua_waf

git clone https://github.com/loveshell/ngx_lua_waf.git

将git获取的文件放到nginx的conf目录下

在nginx.conf的http段添加

lua_package_path "/usr/local/openresty/nginx/conf/ngx_lua_waf/?.lua";

lua_shared_dict limit 10m;

init_by_lua_file /usr/local/openresty/nginx/conf/ngx_lua_waf/init.lua;

access_by_lua_file /usr/local/openresty/nginx/conf/ngx_lua_waf/waf.lua;

配置config.lua里的waf规则目录(一般在ngx_lua_waf/wafconf/目录下)

RulePath = "/usr/local/openresty/nginx/conf/ngx_lua_waf/wafconf"

attacklog = "on"

logdir = "/usr/local/nginx/logs/waf"

 

3、waf日志配置

#将nginx.conf首行的”# user nobody;”的”#”注释去掉,重新启动nginx服务 user nobody #将防护日志目录所属user和group修改为nobody,目录权限可设为700也可以写入,当然也可以默认

cd /usr/local/nginx/conf

//chown -R nobay.nobady waf

//chmod 700 waf


因为nginx、php模块等是单独安装的,所以每次重启服务器都需要重启相应的服务

启动nginx

cd  /usr/local/openresty/nginx/sbin

./nginx   (不关闭nginx而重新加载配置文件   ./nginx  -t)




0x2  nginx_lua_waf测试

启动php

直接执行/usr/sbin/php-fpm

测试SQL注入漏洞

nginx_lua_waf安装测试


测试结果

nginx_lua_waf安装测试


测试任意文件读取

nginx_lua_waf安装测试


进行CC***测试

nginx_lua_waf安装测试


通过查看waf_logs可以看到waf拦截的所有的***操作

nginx_lua_waf安装测试


通过waf_logs可以看到无论是sql注入、任意文件读取还是CC***都被成功的拦截,waf的部署是成功可靠的!


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI