Merge ac2bd7246b
into 314a2f62ec
commit
58109c3d94
35
README.md
35
README.md
|
@ -1,4 +1,4 @@
|
|||
##ngx_lua_waf
|
||||
## ngx_lua_waf
|
||||
|
||||
ngx_lua_waf是我刚入职趣游时候开发的一个基于ngx_lua的web应用防火墙。
|
||||
|
||||
|
@ -6,7 +6,7 @@ ngx_lua_waf是我刚入职趣游时候开发的一个基于ngx_lua的web应用
|
|||
|
||||
现在开源出来,遵从MIT许可协议。其中包含我们的过滤规则。如果大家有什么建议和想fa,欢迎和我一起完善。
|
||||
|
||||
###用途:
|
||||
### 用途:
|
||||
|
||||
防止sql注入,本地包含,部分溢出,fuzzing测试,xss,SSRF等web攻击
|
||||
防止svn/备份之类文件泄漏
|
||||
|
@ -16,37 +16,39 @@ ngx_lua_waf是我刚入职趣游时候开发的一个基于ngx_lua的web应用
|
|||
屏蔽图片附件类目录php执行权限
|
||||
防止webshell上传
|
||||
|
||||
###推荐安装:
|
||||
### 推荐安装:
|
||||
|
||||
推荐使用lujit2.1做lua支持
|
||||
|
||||
ngx_lua如果是0.9.2以上版本,建议正则过滤函数改为ngx.re.find,匹配效率会提高三倍左右。
|
||||
|
||||
|
||||
###使用说明:
|
||||
### 使用说明:
|
||||
|
||||
nginx安装路径假设为:/usr/local/nginx/conf/
|
||||
|
||||
把ngx_lua_waf下载到conf目录下,解压命名为waf
|
||||
|
||||
在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;
|
||||
```
|
||||
|
||||
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;
|
||||
|
||||
配置config.lua里的waf规则目录(一般在waf/conf/目录下)
|
||||
|
||||
RulePath = "/usr/local/nginx/conf/waf/wafconf/"
|
||||
`RulePath = "/usr/local/nginx/conf/waf/wafconf/"`
|
||||
|
||||
绝对路径如有变动,需对应修改
|
||||
|
||||
然后重启nginx即可
|
||||
|
||||
|
||||
###配置文件详细说明:
|
||||
|
||||
### 配置文件详细说明:
|
||||
```
|
||||
RulePath = "/usr/local/nginx/conf/waf/wafconf/"
|
||||
--规则存放目录
|
||||
attacklog = "off"
|
||||
|
@ -77,8 +79,9 @@ nginx安装路径假设为:/usr/local/nginx/conf/
|
|||
html=[[Please go away~~]]
|
||||
--警告内容,可在中括号内自定义
|
||||
备注:不要乱动双引号,区分大小写
|
||||
|
||||
###检查规则是否生效
|
||||
```
|
||||
|
||||
### 检查规则是否生效
|
||||
|
||||
部署完毕可以尝试如下命令:
|
||||
|
||||
|
@ -88,13 +91,13 @@ nginx安装路径假设为:/usr/local/nginx/conf/
|
|||
注意:默认,本机在白名单不过滤,可自行调整config.lua配置
|
||||
|
||||
|
||||
###效果图如下:
|
||||
### 效果图如下:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
###规则更新:
|
||||
### 规则更新:
|
||||
|
||||
考虑到正则的缓存问题,动态规则会影响性能,所以暂没用共享内存字典和redis之类东西做动态管理。
|
||||
|
||||
|
@ -102,7 +105,7 @@ nginx安装路径假设为:/usr/local/nginx/conf/
|
|||
|
||||
只记录过滤日志,不开启过滤,在代码里在check前面加上--注释即可,如果需要过滤,反之
|
||||
|
||||
###一些说明:
|
||||
### 一些说明:
|
||||
|
||||
过滤规则在wafconf下,可根据需求自行调整,每条规则需换行,或者用|分割
|
||||
|
||||
|
|
Loading…
Reference in New Issue