修改下面的代码直到能用为止function denycc if CCDeny then local uri=ngxvaruri CCcount=tonumberstringmatchCCrate CCseconds=tonumberstringmatchCCrate local token = getClientIpuri
function denycc() if CCDeny then local uri = ngx.var.uri local CCrate = ngx.var.limit_rate local CCcount = tonumber(string.match(CCrate, '(.)/')) local CCseconds = tonumber(string.match(CCrate, '/(.)')) local token = getClientIp() .. uri local limit = ngx.shared.limit local req = limit:get(token) local ip = getClientIp() local block = limit:get(ip)
if block then
return ngx.exit(444)
end
if req then
if req > CCcount then
limit:set(ip, 1, DenySeconds)
return ngx.exit(444)
else
limit:incr(token, 1)
end
else
limit:set(token, 1, CCseconds)
end
end
return false
en
原文地址: https://www.cveoy.top/t/topic/gUTE 著作权归作者所有。请勿转载和采集!