stream - fix various errors

This commit is contained in:
bunkerity 2023-04-25 18:07:39 +02:00
parent bc1dbe18a8
commit c7bc493e35
9 changed files with 21 additions and 13 deletions

View File

@ -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")

View File

@ -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")

View File

@ -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;

View File

@ -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 }};
}

View File

@ -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)

View File

@ -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)

View File

@ -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" +%}

View File

@ -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

View File

@ -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