diff --git a/config.lua b/config.lua index 3a6b055..fc0749c 100644 --- a/config.lua +++ b/config.lua @@ -10,7 +10,7 @@ post_check = false black_file_ext = {"php", "jsp"} attack_log = false -attach_log_dir = "/usr/local/nginx/logs/hack/" +attach_log_dir = "/data/logs/waf/" redirect = false redirect_url = "http://www.baidu.com" diff --git a/init.lua b/init.lua index 47e701b..33ce253 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,3 @@ --- require 'config' local match = string.match local ngx_match = ngx.re.match local unescape = ngx.unescape_uri @@ -199,13 +198,20 @@ function denyCC(cc_rate, cc_deny_seconds) local block, _ = limit:get(ip) if block then - ngx.exit(405) + if debug then + ngx.say('Deny by waf.') + return false + elseif cc_redirect then + ngx.redirect(cc_redirect_url) + else + ngx.exit(404) + end end if req then if req > cc_count then limit:set(ip, 1, cc_deny_seconds) - ngx.exit(405) + ngx.exit(404) return false else limit:incr(token, 1)