diff --git a/access.lua b/access.lua
index 5d27920..ec615f9 100644
--- a/access.lua
+++ b/access.lua
@@ -1,5 +1,12 @@
require "init"
+-- captcha url
+if ngx.re.match(ngx.var.request_uri,"^/captcha-waf.html","jo") then
+ ngx.header.content_type = "text/html"
+ ngx.say(config_waf_captcha_html)
+ ngx.exit(200)
+end
+
local function waf_main()
if black_ip_check() then
elseif white_ip_check() then
diff --git a/config.lua b/config.lua
index ad5bc71..29577bd 100644
--- a/config.lua
+++ b/config.lua
@@ -23,13 +23,103 @@ config_cookie_check = "on"
--enable/disable cc filtering
config_cc_check = "on"
--cc rate the xxx of xxx seconds
-config_cc_rate = "120/120"
+config_cc_rate = "60/60"
--enable/disable post filtering
config_post_check = "on"
--config waf output redirect/html
config_waf_output = "html"
--if config_waf_output ,setting url
config_waf_redirect_url = "/captcha"
+config_waf_captcha_html=[[
+
+
+
+ Please enter verification code - OneinStack WAF
+
+
+
+
+
Sorry...
+
Your query looks similar to an automated request from computer software. In order to protect our users, please forgive us for temporarily not processing your request.
+
To continue accessing the webpage, please enter the characters shown below:
+
+
+
+
+
+
+]]
config_output_html=[[
diff --git a/init.lua b/init.lua
index c8ed5f7..f215c7a 100644
--- a/init.lua
+++ b/init.lua
@@ -14,7 +14,7 @@ function white_ip_check()
if IP_WHITE_RULE ~= nil then
for _,rule in pairs(IP_WHITE_RULE) do
if rule ~= "" and rulematch(WHITE_IP,rule,"jo") then
- -- log_record("White_IP",ngx.var_request_uri,"_","_")
+ -- log_record("White_IP",ngx.var.request_uri,"_","_")
return true
end
end
@@ -30,7 +30,7 @@ function black_ip_check()
if IP_BLACK_RULE ~= nil then
for _,rule in pairs(IP_BLACK_RULE) do
if rule ~= "" and rulematch(BLACK_IP,rule,"jo") then
- log_record('BlackList_IP',ngx.var_request_uri,"_","_")
+ log_record('BlackList_IP',ngx.var.request_uri,"_","_")
if config_waf_enable == "on" then
ngx.header.content_type = "text/html"
ngx.say('Your IP blacklist, Please contact the administrator! ')
@@ -75,10 +75,10 @@ function cc_attack_check()
if req then
-- write("/data/wwwlogs/info.log",CC_TOKEN .."\t".. ATTACK_URL .. "\t".. "req: " .. req .."\n")
if req > CCcount then
- log_record("CC_Attack",ATTACK_URL,"-","-")
+ log_record("CC_Attack",ngx.var.request_uri,"-","-")
if config_waf_enable == "on" then
local source = ngx.encode_base64(ngx.var.scheme.."://"..ngx.var.host..ngx.var.request_uri)
- local dest = 'https://oneinstack.com/captcha.html' .. '?continue=' .. source
+ local dest = '/captcha-waf.html' .. '?continue=' .. source
local CCcountcode,_ = math.modf(CCcount/2);
limit:set(CC_TOKEN,CCcountcode)
ngx.redirect(dest,302)
@@ -155,6 +155,7 @@ function url_args_attack_check()
end
return false
end
+
-- deny user agent
function user_agent_attack_check()
if config_user_agent_check == "on" then
diff --git a/wafconf/whiteurl b/wafconf/whiteurl
index b1eb0f1..31be0d7 100644
--- a/wafconf/whiteurl
+++ b/wafconf/whiteurl
@@ -1,3 +1,4 @@
\.(js|css)
-\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)
+\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico|map)
+captcha-waf\.html
403\.html