mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
bw - fix missing location header in http to https redirects
This commit is contained in:
parent
1f6a55c4e0
commit
de98fe4bb9
5 changed files with 20 additions and 2 deletions
|
|
@ -115,6 +115,7 @@ access_by_lua_block {
|
|||
end
|
||||
logger:log(NOTICE, plugin_id .. " redirect to " .. ret.redirect .. " : " .. ret.msg)
|
||||
redirect = ret.redirect
|
||||
ctx.bw.location_header = redirect
|
||||
break
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ function errors:initialize(ctx)
|
|||
plugin.initialize(self, "errors", ctx)
|
||||
-- Default error texts
|
||||
self.default_errors = {
|
||||
["301"] = {
|
||||
title = "Moved Permanently",
|
||||
text = "The requested page has moved to a new url.",
|
||||
},
|
||||
["302"] = {
|
||||
title = "Found",
|
||||
text = "The requested page has moved temporarily to a new url.",
|
||||
},
|
||||
["400"] = {
|
||||
title = "Bad Request",
|
||||
text = "The server did not understand the request.",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
},
|
||||
"INTERCEPTED_ERROR_CODES": {
|
||||
"context": "multisite",
|
||||
"default": "400 401 403 404 405 413 429 500 501 502 503 504",
|
||||
"default": "301 302 400 401 403 404 405 413 429 500 501 502 503 504",
|
||||
"help": "List of HTTP error code intercepted by BunkerWeb",
|
||||
"id": "intercepted-error-codes",
|
||||
"label": "Intercepted error codes",
|
||||
|
|
|
|||
|
|
@ -46,6 +46,15 @@ function misc:access()
|
|||
return self:ret(true, "method " .. method .. " is not allowed", HTTP_NOT_ALLOWED)
|
||||
end
|
||||
|
||||
function misc:header()
|
||||
-- Add Location header if needed
|
||||
if self.ctx.bw.location_header then
|
||||
ngx.header["Location"] = self.ctx.bw.location_header
|
||||
return self:ret(true, "edited location header")
|
||||
end
|
||||
return self:ret(true, "no location header needed")
|
||||
end
|
||||
|
||||
function misc:log_default()
|
||||
if self.variables["DISABLE_DEFAULT_SERVER"] == "yes" then
|
||||
self:set_metric("counters", "failed_default", 1)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
"cors",
|
||||
"antibot"
|
||||
],
|
||||
"headers": ["headers", "cors", "reverseproxy", "clientcache", "antibot"],
|
||||
"headers": ["headers", "cors", "reverseproxy", "clientcache", "antibot", "misc"],
|
||||
"log": ["badbehavior", "bunkernet", "errors", "metrics"],
|
||||
"preread": [
|
||||
"whitelist",
|
||||
|
|
|
|||
Loading…
Reference in a new issue