ngx_waf 核心规则 :
naxsi_core.rules 配置参考naxsi_core.rules naxsi/naxsi_core.rules at master · nbs-system/naxsi · GitHubhttps://github.com/nbs-system/naxsi/blob/master/naxsi_config/naxsi_core.rules
白名单规则(naxsi_mysite.rules):
SecRulesEnabled;
DeniedUrl "/RequestDenied";
CheckRule "$SQL >= 8" BLOCK;
CheckRule "$RFI >= 8" BLOCK;
CheckRule "$TRAVERSAL >=4" BLOCK;
CheckRule "$EVADE >= 4" BLOCK;
CheckRule "$XSS >= 8" BLOCK;
如果需要制定日志路径 可以在location 添加
error_log /data/openresty/logs/naxsi.log;#配置Naxsi错误日志
白名单配置(naxsi_white.rules):
BasicRule wl:0 "mz:$HEADERS_VAR:cookie";
BasicRule wl:0 "mz:$ARGS_VAR:timstape";
BasicRule wl:0 "mz:$ARGS_VAR:timestape";
BasicRule wl:15 "mz:$URL:/elastic/login!getCookie.do|BODY";
BasicRule wl:1402 "mz:$URL:/elastic/login!getCookie.do|$HEADERS_VAR:content-type";
BasicRule wl:1000 "mz:$URL:/elastic/css/form_table.css|URL";
BasicRule wl:1005 "mz:$URL:/elastic/jtmg/notice_add.do|$BODY_VAR:noticeinfo.channelcode";
BasicRule wl:1008 "mz:$URL:/elastic/jtmg/warnMsg!queryWarnNoConfig.do|BODY";
BasicRule wl:1008 "mz:$URL:/elastic/ninclude/html{cursor:text;*cursor:auto}img,input,textarea{cursor:default}|URL";
BasicRule wl:1100 "mz:$URL:/elastic/system/os/os!update.do|$BODY_VAR:url";
BasicRule wl:1100,1101 "mz:$URL:/elastic/jtmg/saleruleinfoV2!modify.do|BODY";
BasicRule wl:1015 "mz:$URL:/elastic/jtmg/salerule!save.do|$BODY_VAR:salecode";
BasicRule wl:1015 "mz:$URL:/elastic/jtmg/testPhoneNo!delete.do|$ARGS_VAR:idstring";
BasicRule wl:1302 "mz:URL";
BasicRule wl:1100 "mz:$BODY_VAR:url";
BasicRule wl:1015 "mz:$URL:/elastic/system/role/rolemanage!update.do|$BODY_VAR:funcstring";
BasicRule wl:1000 "mz:$URL:/elastic/system/role/rolemanage!update.do|$BODY_VAR:updatebtn|NAME";
MatchZone (mz:...)配置参考(白名单配置):
ARGS: GET的整个参数内容,如: foo=bar&in=%20
$ARGS_VAR: GET参数的参数名, 如 foo=bar&in=%20中的 foo和in。
$ARGS_VAR_X: 正则匹配的GET参数的参数名
HEADERS: 整个HTTP协议头内容
$HEADERS_VAR: HTTP协议头的参数名
$HEADERS_VAR_X: 正则匹配的HTTP协议头的参数名
BODY: POST的整个参数内容
$BODY_VAR: POST参数的参数名
$BODY_VAR_X: 正则匹配的POST参数的参数名
URL(整个链接?前的部分链接)
$URL:域名后的路径
$URL_X: 正则匹配的URL(整个链接?前的部分链接)
FILE_EXT: 文件名 (POST上传文件时上传的文件名)
RAW_BODY: HTTP请求的BODY部分的原始的未解析的内容
nginx 中可以添加配置,对于上面处于拦截的接口的友好提示
location /RequestDenied {
charset gb2312;
echo '{"retCode":"500001","retMsg":"parameter illegal!"}';
return 403;
}
参考:naxsi/naxsi_core.rules at master · nbs-system/naxsi · GitHub