• 欢迎光临~

Openresty 配置 waf

开发技术 开发技术 2022-12-01 次浏览

安装openresty

cd /usr/local
mkdir openresty
cd openresty
wget https://openresty.org/download/openresty-1.21.4.1.tar.gz
tar -xvf openresty-1.21.4.1.tar.gz 
yum install readline-devel pcre-devel openssl-devel gcc
cd openresty-1.21.4.1
./configure --prefix=/usr/local/openresty/server --with-luajit --with-http_stub_status_module --with-pcre --with-pcre-jit --with-http_gzip_static_module --with-http_ssl_module
gmake && gmake install
cd ../server/
./nginx/sbin/nginx

配置waf

cd /usr/local/openresty/server/nginx/conf
git clone https://gitee.com/yanglei_xyz/ngx_lua_waf.git
mv ngx_lua_waf waf

在nginx.conf的http段添加

#WAF
lua_package_path "/usr/local/openresty/server/nginx/conf/waf/?.lua";
lua_shared_dict limit 10m;
init_by_lua_file  /usr/local/openresty/server/nginx/conf/waf/init.lua;
access_by_lua_file /usr/local/openresty/server/nginx/conf/waf/waf.lua;

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

RulePath = "/usr/local/openresty/server/nginx/conf/waf/wafconf/"
logdir = "/usr/local/openresty/server/nginx/logs/hack/"

添加软连接

ln -s /usr/local/openresty/server/lualib /usr/local/lib/lua
ln -s /usr/local/openresty/server/lualib/resty /usr/local/openresty/server/nginx/conf/waf/resty

重新启动openresty

cd /usr/local/openresty/server/nginx/sbin
./nginx -s reload

查看是否生效

Openresty 配置 waf

 

程序员灯塔
转载请注明原文链接:Openresty 配置 waf
喜欢 (0)
违法和不良信息举报电话:022-22558618 举报邮箱:dljd@tidljd.com