ngx_lua_waf是一款开源的 基于 ngx_lua的 web应用防火墙
github地址是 https://github.com/loveshell/ngx_lua_waf
安装流程如下
1 安装 lua 环境
wget http://luajit.org/download/LuaJIT-2.0.3.tar.gz tar xf LuaJIT-2.0.3.tar.gz cd LuaJIT-2.0.3 make && make install ln -sv /usr/local/lib/libluajit-5.1.so.2.0.3 /lib64/libluajit-5.1.so.2
2 下载ngx_devel_kit并解压
wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz tar xf v0.2.19.tar.gz
3 下载ngx_lua并解压
wget https://github.com/chaoslawful/lua-nginx-module/archive/v0.9.6.tar.gz tar xf v0.9.6.tar.gz
4 重新编译安装nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-pcre=/home/soft/pcre-8.31 --add-module=/home/lua-nginx-module-0.9.6 --add-module=/home/ngx_devel_kit-0.2.19 make 添加模块 先备份之前的 ngxin文件 cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak cp ./objs/nginx /usr/local/nginx/sbin/
5 下载ngx_lua_waf并解压
wget https://github.com/loveshell/ngx_lua_waf/archive/master.zip unzip master.zip mv master /usr/local/nginx/ngx_lua_waf/
6 修改 nginx的配置文件 根据实际情况更改路径
lua_need_request_body on; lua_package_path \"/usr/local/nginx/conf/ngx_lua_waf/?.lua\"; lua_shared_dict limit 10m; init_by_lua_file /usr/local/nginx/conf/ngx_lua_waf/init.lua; access_by_lua_file /usr/local/nginx/conf/ngx_lua_waf/waf.lua;
最后测试 重启nginx