From 95ba84a69e65da36a6b86eda1208bc248746cd91 Mon Sep 17 00:00:00 2001 From: lijie3 Date: Fri, 31 Mar 2023 10:07:35 +0800 Subject: [PATCH 1/3] fix tcp 502 error --- rootfs/etc/nginx/lua/tcp_udp_configuration.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rootfs/etc/nginx/lua/tcp_udp_configuration.lua b/rootfs/etc/nginx/lua/tcp_udp_configuration.lua index 85864b45b..e93b80db7 100644 --- a/rootfs/etc/nginx/lua/tcp_udp_configuration.lua +++ b/rootfs/etc/nginx/lua/tcp_udp_configuration.lua @@ -1,5 +1,6 @@ local ngx = ngx local tostring = tostring +local cjson = require("cjson.safe") -- this is the Lua representation of TCP/UDP Configuration local tcp_udp_configuration_data = ngx.shared.tcp_udp_configuration_data @@ -37,6 +38,14 @@ function _M.call() return end + _, err = cjson.decode(backends) + + if err then + ngx.log(ngx.ERR, "could not parse backends data: ", err) + return + end + + local success, err_conf = tcp_udp_configuration_data:set("backends", backends) if not success then ngx.log(ngx.ERR, "dynamic-configuration: error updating configuration: " .. tostring(err_conf)) From 0853562bc90af52d78ecd470d4a0105ea022f427 Mon Sep 17 00:00:00 2001 From: lijie Date: Wed, 14 Jun 2023 09:59:48 +0800 Subject: [PATCH 2/3] fix tcp 502 error for parse tcp backend data --- rootfs/etc/nginx/lua/tcp_udp_configuration.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/nginx/lua/tcp_udp_configuration.lua b/rootfs/etc/nginx/lua/tcp_udp_configuration.lua index e93b80db7..caf6bffff 100644 --- a/rootfs/etc/nginx/lua/tcp_udp_configuration.lua +++ b/rootfs/etc/nginx/lua/tcp_udp_configuration.lua @@ -38,7 +38,7 @@ function _M.call() return end - _, err = cjson.decode(backends) + local _, err = cjson.decode(backends) if err then ngx.log(ngx.ERR, "could not parse backends data: ", err) From a8749d4fec1a5865bbb71e75339ee1cdba44a730 Mon Sep 17 00:00:00 2001 From: lijie Date: Wed, 14 Jun 2023 10:26:15 +0800 Subject: [PATCH 3/3] fix tcp 502 error for parse tcp backend data --- rootfs/etc/nginx/lua/tcp_udp_configuration.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rootfs/etc/nginx/lua/tcp_udp_configuration.lua b/rootfs/etc/nginx/lua/tcp_udp_configuration.lua index caf6bffff..f191454fa 100644 --- a/rootfs/etc/nginx/lua/tcp_udp_configuration.lua +++ b/rootfs/etc/nginx/lua/tcp_udp_configuration.lua @@ -38,10 +38,10 @@ function _M.call() return end - local _, err = cjson.decode(backends) + local _, backends_err = cjson.decode(backends) - if err then - ngx.log(ngx.ERR, "could not parse backends data: ", err) + if backends_err then + ngx.log(ngx.ERR, "could not parse backends data: ", backends_err) return end