mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
fix wrong log in access
This commit is contained in:
parent
8e22b1f219
commit
a83254bf20
2 changed files with 26 additions and 1 deletions
|
@ -84,4 +84,29 @@ helpers.call_plugin = function(plugin, method)
|
||||||
return true, ret
|
return true, ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
helpers.fill_ctx = function()
|
||||||
|
-- Check if ctx is already filled
|
||||||
|
if ngx.ctx.bw then
|
||||||
|
return true, "already filled"
|
||||||
|
end
|
||||||
|
-- Return errors as table
|
||||||
|
local errors = {}
|
||||||
|
-- Instantiate bw table
|
||||||
|
local data = {}
|
||||||
|
-- Common vars
|
||||||
|
data.ip = ngx.var.remote_addr
|
||||||
|
data.uri = ngx.var.uri
|
||||||
|
data.original_uri = ngx.var.original_uri
|
||||||
|
data.user_agent = ngx.var.http_user_agent
|
||||||
|
-- Global IP
|
||||||
|
local ip_is_global, err = utils.ip_is_global(data.ip)
|
||||||
|
if ip_is_global == nil then
|
||||||
|
table.insert(errors, "can't check if IP is global : " .. err)
|
||||||
|
else
|
||||||
|
data.ip_is_global = ip_is_global
|
||||||
|
end
|
||||||
|
-- ctx filled
|
||||||
|
return true, "ctx filled", errors
|
||||||
|
end
|
||||||
|
|
||||||
return helpers
|
return helpers
|
|
@ -78,7 +78,7 @@ for i, plugin in ipairs(plugins) do
|
||||||
ngx.ctx.reason = plugin.id
|
ngx.ctx.reason = plugin.id
|
||||||
logger:log(ngx.WARN, "denied access from " .. plugin.id .. " : " .. err)
|
logger:log(ngx.WARN, "denied access from " .. plugin.id .. " : " .. err)
|
||||||
else
|
else
|
||||||
logger:log(ngx.NOTICE, plugin.id .. " returned status " .. tostring(ret.status) .. " : " .. err)
|
logger:log(ngx.NOTICE, plugin.id .. " returned status " .. tostring(ret.status))
|
||||||
end
|
end
|
||||||
ngx.ctx.status = ret.status
|
ngx.ctx.status = ret.status
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue