pull/63/head
ibuler 2016-06-18 14:56:30 +08:00
parent d919acf558
commit db6eda926b
2 changed files with 10 additions and 4 deletions

View File

@ -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"

View File

@ -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)