首页 > 代码库 > ngx_lua_waf完整安装说明

ngx_lua_waf完整安装说明

测试环境:
centos5.6 x32,nginx1.4.4,LuaJIT-2.0.3,ngx_devel_kit-0.2.19、lua-nginx-module-0.9.11,ngx_lua_waf

1、安装nginx_lua_module模块mkdir /data/soft上传nginx1.4.4,LuaJIT-2.0.3,ngx_devel_kit-0.2.19、lua-nginx-module-0.9.11unzip LuaJIT-2.0.3.zipcd LuaJIT-2.0.3make&&make install出现如下内容,表示安装成功==== Successfully installed LuaJIT 2.0.3 to /usr/local ====tar -zxvf ngx_devel_kit-0.2.19.tar.gztar -zxvf lua-nginx-module-0.9.11.tar.gz以下为以/usr/local/nginx/conf/nginx.conf中加入作为nginx安装路径为例说明tar -zxvf nginx-1.4.4cd nginx-1.4.4 export LUAJIT_LIB=/usr/local/libexport LUAJIT_INC=/usr/local/include/luajit-2.0export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH  ./configure --prefix=/usr/local/nginx --add-module=/data/soft/ngx_devel_kit-0.2.19 --add-module=/data/soft/lua-nginx-module-0.9.11make -j2make install/usr/local/nginx/conf/nginx.conf中加入以下内容并保存server{......    location /hello {           default_type text/plain;           content_by_lua ngx.say("hello, lua");     }}/usr/local/nginx/sbin/nginx –t 检查nginx配置,应无报错/usr/local/nginx/sbin/nginx 访问localhost/hello,会出现“hello,lua,说明安装成功!2、安装并配置ngx_lua_wafcd /usr/local/nginx/confrz 上传ngx_lua_waf-master.ziptar -zxvf ngx_lua_waf-master.ziprm ngx_lua_waf-master.zipmv ngx_lua_waf-master wafvi conf/nginx.conf,在http段添加以下内容并保存退出    lua_package_path "/usr/local/nginx/conf/waf/?.lua";    lua_shared_dict limit 10m;    init_by_lua_file  /usr/local/nginx/conf/waf/init.lua;     access_by_lua_file /usr/local/nginx/conf/waf/waf.lua;以nginx进程用户为www为例说明mkdir -R /usr/local/nginx/logs/hackchown -R www:www /usr/local/nginx/logs/hack/chmod -R 755 /usr/local/nginx/logs/hack/如果nginx安装路径和攻击日志存储路径与上述示例不一致,需要vi waf /config.lua修改RulePath和logdir重启nginx/usr/local/nginx/sbin/nginx –s reload访问:域名/etc/passwd,页面提示:Please go away~~ ,同时/usr/local/nginx/logs/hack/目录下生成类似server_name-2014-08-26_sec.log的文件,说明安装配置成功如果需要修改页面提示内容,可以修改config.lua中的html字段内容为:403 Fprbiddenrm -rf /data/softl

参考文档:http://www.cnblogs.com/yjf512/archive/2012/03/27/2419577.html

ngx_lua_waf完整安装说明