feat: improve logging in access.lua
This commit is contained in:
parent
19adda03d9
commit
09b178dca8
1 changed files with 12 additions and 7 deletions
|
@ -7,6 +7,7 @@ local utils = require "utils"
|
|||
local jasima_host = config.get_jasima_host()
|
||||
ngx.ctx.jasima_host = jasima_host
|
||||
if not jasima_host then
|
||||
ngx.log(ngx.DEBUG, "no host specified via header or cookie")
|
||||
return ngx.exit(400)
|
||||
end
|
||||
|
||||
|
@ -14,21 +15,25 @@ local err
|
|||
ngx.ctx.jasima_config, err = config.load_config(jasima_host)
|
||||
if err then
|
||||
ngx.status = 500
|
||||
ngx.log(ngx.ERR, "Could not load config: " .. err)
|
||||
ngx.log(ngx.ERR, "could not load config: " .. err)
|
||||
return ngx.exit(500)
|
||||
end
|
||||
|
||||
if not ngx.ctx.jasima_config then
|
||||
ngx.status = 403
|
||||
ngx.log(ngx.ERR, "Requested a canonical host that has no configuration specified: " .. jasima_host)
|
||||
ngx.log(ngx.INFO, "requested a canonical host that has no configuration specified: " .. jasima_host)
|
||||
ngx.exit(403)
|
||||
end
|
||||
|
||||
local country = geo.viewer_country()
|
||||
if not ngx.ctx.jasima_config.geo_redirect_disable and not geo.needs_mirror(country) then
|
||||
if not ngx.ctx.jasima_config.geo_redirect_disable then
|
||||
ngx.log(ngx.DEBUG, "geo_redirect_disable not configured for site " .. jasima_host)
|
||||
if not geo.needs_mirror(country) then
|
||||
ngx.log(ngx.DEBUG, "mirror is not needed for viewer in " .. country .. " for " .. jasima_host .. ", redirecting")
|
||||
local request_uri = ngx.var.request_uri
|
||||
local new_url = "https://" .. jasima_host .. request_uri
|
||||
return ngx.redirect(new_url, ngx.HTTP_MOVED_TEMPORARILY)
|
||||
end
|
||||
end
|
||||
|
||||
-- Get jasima_pool (not critical)
|
||||
|
@ -36,7 +41,7 @@ local jasima_pool = config.get_jasima_pool()
|
|||
ngx.ctx.jasima_pool_map, err = config.load_pool_mapping(jasima_pool)
|
||||
if err then
|
||||
ngx.status = 500
|
||||
ngx.log(ngx.WARN, "Could not load pool mapping: " .. err)
|
||||
ngx.log(ngx.WARN, "could not load requested pool mapping: " .. err)
|
||||
return ngx.exit(500)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue