Update init.lua

增加白名单功能。
whiteurl文件中使用site:^www.abc.com/aa/bb/cc.html$针对域名做白名单限制。
pull/96/head
weakestan 2016-05-23 18:08:22 +08:00
parent 314a2f62ec
commit 3e8f7eacd0
1 changed files with 12 additions and 3 deletions

View File

@ -78,12 +78,21 @@ function whiteurl()
if WhiteCheck then if WhiteCheck then
if wturlrules ~=nil then if wturlrules ~=nil then
for _,rule in pairs(wturlrules) do for _,rule in pairs(wturlrules) do
--针对site:开始的进行域名匹配。增加白名单用处。
local sitemod,_=string.find(rule,"site:")
if sitemod==1 then
rule=string.gsub(rule,"site:","",1)
if ngxmatch(ngx.var.host..ngx.var.uri,rule,"isjo") then
return true
end
else
if ngxmatch(ngx.var.uri,rule,"isjo") then if ngxmatch(ngx.var.uri,rule,"isjo") then
return true return true
end end
end end
end end
end end
end
return false return false
end end
function fileExtCheck(ext) function fileExtCheck(ext)