diff --git a/src/common/confs/server-http/log-lua.conf b/src/common/confs/server-http/log-lua.conf index 0d8f0367e..532840ff0 100644 --- a/src/common/confs/server-http/log-lua.conf +++ b/src/common/confs/server-http/log-lua.conf @@ -66,7 +66,7 @@ logger:log(ngx.INFO, "called log() methods of plugins") -- Display reason at info level if ngx.ctx.reason then - logger:log(ngx.INFO, "client was denied with reason : " .. reason) + logger:log(ngx.INFO, "client was denied with reason : " .. ngx.ctx.reason) end logger:log(ngx.INFO, "log phase ended") diff --git a/src/common/confs/server-stream/log-stream-lua.conf b/src/common/confs/server-stream/log-stream-lua.conf index 4e5e2c5ab..337b0437c 100644 --- a/src/common/confs/server-stream/log-stream-lua.conf +++ b/src/common/confs/server-stream/log-stream-lua.conf @@ -66,7 +66,7 @@ logger:log(ngx.INFO, "called log_stream() methods of plugins") -- Display reason at info level if ngx.ctx.reason then - logger:log(ngx.INFO, "client was denied with reason : " .. reason) + logger:log(ngx.INFO, "client was denied with reason : " .. ngx.ctx.reason) end logger:log(ngx.INFO, "log phase ended") diff --git a/src/common/confs/server-stream/server-stream.conf b/src/common/confs/server-stream/server-stream.conf index ca55e6a8a..cae07afe3 100644 --- a/src/common/confs/server-stream/server-stream.conf +++ b/src/common/confs/server-stream/server-stream.conf @@ -14,6 +14,9 @@ server { # reason variable set $reason ''; + # server_name variable + set $server_name '{{ SERVER_NAME.split(" ")[0] }}'; + # include LUA files include {{ NGINX_PREFIX }}preread-stream-lua.conf; include {{ NGINX_PREFIX }}log-stream-lua.conf; diff --git a/src/common/confs/stream.conf b/src/common/confs/stream.conf index 30b4e3591..3c9a880fa 100644 --- a/src/common/confs/stream.conf +++ b/src/common/confs/stream.conf @@ -65,7 +65,7 @@ include /etc/nginx/init-worker-stream-lua.conf; {% endfor %} {% for first_server in map_servers +%} include /etc/nginx/{{ first_server }}/server-stream.conf; -{% if all[first_server + "_REVERSE_PROXY_HOST"] != "" +%} +{% if all[first_server + "_USE_REVERSE_PROXY"] == "yes" and all[first_server + "_REVERSE_PROXY_HOST"] != "" +%} upstream {{ first_server }} { server {{ all[first_server + "_REVERSE_PROXY_HOST"] }}; } @@ -73,7 +73,7 @@ upstream {{ first_server }} { {% endfor %} {% elif MULTISITE == "no" and SERVER_NAME != "" and SERVER_TYPE == "stream" +%} include /etc/nginx/server-stream.conf; -{% if REVERSE_PROXY_HOST != "" +%} +{% if USE_REVERSE_PROXY == "yes" and REVERSE_PROXY_HOST != "" +%} upstream {{ SERVER_NAME.split(" ")[0] }} { server {{ REVERSE_PROXY_HOST }}; } diff --git a/src/common/core/antibot/antibot.lua b/src/common/core/antibot/antibot.lua index d80932e71..d33679727 100644 --- a/src/common/core/antibot/antibot.lua +++ b/src/common/core/antibot/antibot.lua @@ -8,7 +8,10 @@ local base64 = require "base64" local sha256 = require "resty.sha256" local str = require "resty.string" local http = require "resty.http" -local template = require "resty.template" +local template = nil +if ngx.shared.datastore then + template = require "resty.template" +end local antibot = class("antibot", plugin) diff --git a/src/common/core/errors/errors.lua b/src/common/core/errors/errors.lua index 0a9a367e6..ed9ddb704 100644 --- a/src/common/core/errors/errors.lua +++ b/src/common/core/errors/errors.lua @@ -2,7 +2,10 @@ local class = require "middleclass" local plugin = require "bunkerweb.plugin" local utils = require "bunkerweb.utils" local cjson = require "cjson" -local template = require "resty.template" +local template = nil +if ngx.shared.datastore then + template = require "resty.template" +end local errors = class("errors", plugin) diff --git a/src/common/core/reverseproxy/confs/server-stream/reverse-proxy.conf b/src/common/core/reverseproxy/confs/server-stream/reverse-proxy.conf index 73c1907bd..0bdf135c9 100644 --- a/src/common/core/reverseproxy/confs/server-stream/reverse-proxy.conf +++ b/src/common/core/reverseproxy/confs/server-stream/reverse-proxy.conf @@ -1,4 +1,4 @@ -{% if USE_REVERSE_PROXY == "yes" +%} +{% if USE_REVERSE_PROXY == "yes" and REVERSE_PROXY_HOST != "" +%} # TODO : more settings specific to stream {% if REVERSE_PROXY_STREAM_PROXY_PROTOCOL == "yes" +%} diff --git a/src/common/core/sessions/sessions.lua b/src/common/core/sessions/sessions.lua index 8c9353fc9..10abbe82b 100644 --- a/src/common/core/sessions/sessions.lua +++ b/src/common/core/sessions/sessions.lua @@ -11,7 +11,7 @@ function sessions:initialize() end function sessions:init() - if self.is_loading then + if self.is_loading or self.kind ~= "http" then return self:ret(true, "init not needed") end -- Get redis vars diff --git a/src/common/core/whitelist/whitelist.lua b/src/common/core/whitelist/whitelist.lua index 21819ef17..52fdb6f5d 100644 --- a/src/common/core/whitelist/whitelist.lua +++ b/src/common/core/whitelist/whitelist.lua @@ -165,11 +165,10 @@ function whitelist:check_cache() if ngx.ctx.bw.uri then checks["URI"] = "uri" .. ngx.ctx.bw.uri end - local already_cached = { - ["IP"] = false, - ["URI"] = false, - ["UA"] = false - } + local already_cached = {} + for i, k in ipairs(checks) do + already_cached[k] = false + end for k, v in pairs(checks) do local ok, cached = self:is_in_cache(v) if not ok then