# openresty_waf **Repository Path**: xmoo/openresty_waf ## Basic Information - **Project Name**: openresty_waf - **Description**: 基于openresty lua脚本的nginx waf - **Primary Language**: Lua - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2018-04-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #ReadMe --- >基于openresty 提供的lua运行环境,开发的具有ip黑名单,ip白名单,user_agent,url黑名单,cc防火墙,特定url匹配的cc防火墙,功能还在进一步加强,特别二次开发,或者学些nginx、lua功能。请一定查看config.lua文件。 - ip白名单 - ip白名单限制速率,随机等待0-指点时间,然后响应 - ip黑名单 - user_agent黑名单 - url黑名单 - 通用cc防火墙 - 特定url匹配防火墙 - 支持正则规则 - ... ##How to use 假定你的openresty目录在/opt/openresty/, cd /opt/openresty/nginx/conf git clone https://git.oschina.net/monkeyzhu/openresty_waf.git 在openresty or nginx config file http{} lua_package_path "/opt/openresty/nginx/conf/openresty_waf/?.lua"; lua_shared_dict limit 200m; init_by_lua_file /opt/openresty/nginx/conf/openresty_waf/init.lua; 在需要访问控制的http|server|location中添加,亦可生成多个waf.lua文件使用。由于此功能略带特殊场景使用,建议将项目简单浏览一遍。或者有任何疑问留言 access_by_lua_file /opt/openresty/nginx/conf/openresty_waf/waf.lua; 注意日志目录的权限。需要为nginx work的用户和组。使用下面的指令获得。前提是你openresty为启动状态。 ps uax|grep nginx|grep worker|awk '{print $1}' 配置项在项目目录下的config.lua文件。规则文件在rule_conf文件夹下,都支持正则表达式,如果对lua正则不太清楚的,不建议使用复杂语法 ip_black_list -- ip黑名单 ip_white_list -- ip白名单 白名单优先级大于黑名单 url_black_list -- url黑名单 user_agent -- user_agent黑名单 url_cc_deny -- 需要做访问频率限制的url,特别适用于在http或server阶段使用。 **Note**由于默认的配置参数并不适用于任何环境,建议用户对访问做一个大概的统计,同时在上线后观察nginx access log的状态码,进一步调整rate值 **Some Link for project** http://nginx.org/en/docs/http/ngx_http_core_module.html $request_uri full original request URI (with arguments) $uri current URI in request, normalized The value of $uri may change during request processing, e.g. when doing internal redirects, or when using index files. lua math random need set randomseed ,the same randomseed produce the same result.