From 3e8f7eacd0a836c0a03f042baa3e2e7e89479315 Mon Sep 17 00:00:00 2001 From: weakestan <22886548@qq.com> Date: Mon, 23 May 2016 18:08:22 +0800 Subject: [PATCH] Update init.lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加白名单功能。 whiteurl文件中使用site:^www.abc.com/aa/bb/cc.html$针对域名做白名单限制。 --- init.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 2eb5966..d732923 100644 --- a/init.lua +++ b/init.lua @@ -78,9 +78,18 @@ function whiteurl() if WhiteCheck then if wturlrules ~=nil then for _,rule in pairs(wturlrules) do - if ngxmatch(ngx.var.uri,rule,"isjo") then - return true - end + --针对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 + return true + end + end end end end