Skip to content

Commit

Permalink
fix(clustering/rpc) support cluster_use_proxy option for clustering…
Browse files Browse the repository at this point in the history
… rpc protocol
  • Loading branch information
chobits committed Dec 3, 2024
1 parent 5e6b1f0 commit a0f954b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 11 additions & 0 deletions kong/clustering/rpc/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,17 @@ function _M:connect(premature, node_id, host, path, cert, key)

local c = assert(client:new(WS_OPTS))

if self.conf.cluster_use_proxy then
local proxy_opts = parse_proxy_url(self.conf.proxy_server)
opts.proxy_opts = {
wss_proxy = proxy_opts.proxy_url,
wss_proxy_authorization = proxy_opts.proxy_authorization,
}

ngx_log(ngx_DEBUG, _log_prefix,
"using proxy ", proxy_opts.proxy_url, " to connect control plane")
end

local ok, err = c:connect(uri, opts)
if not ok then
ngx_log(ngx_ERR, "[rpc] unable to connect to peer: ", err)
Expand Down
10 changes: 7 additions & 3 deletions spec/02-integration/09-hybrid_mode/10-forward-proxy_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ local proxy_configs = {
-- if existing lmdb data is set, the service/route exists and
-- test run too fast before the proxy connection is established

-- XXX FIXME: enable inc_sync = on
for _, inc_sync in ipairs { "off" } do
for _, v in ipairs({ {"off", "off"}, {"on", "off"}, {"on", "on"}, }) do
local rpc, inc_sync = v[1], v[2]
for _, strategy in helpers.each_strategy() do
for proxy_desc, proxy_opts in pairs(proxy_configs) do
describe("CP/DP sync through proxy (" .. proxy_desc .. ") works with #" .. strategy .. " inc_sync=" .. inc_sync .. " backend", function()
describe("CP/DP sync through proxy (" .. proxy_desc .. ") works with #"
.. strategy .. " rpc=" .. rpc .. " inc_sync=" .. inc_sync
.. " backend", function()
lazy_setup(function()
helpers.get_db_utils(strategy) -- runs migrations

Expand All @@ -87,6 +89,7 @@ for _, strategy in helpers.each_strategy() do
db_update_frequency = 0.1,
cluster_listen = "127.0.0.1:9005",
nginx_conf = "spec/fixtures/custom_nginx.template",
cluster_rpc = rpc,
cluster_incremental_sync = inc_sync,
}))

Expand All @@ -108,6 +111,7 @@ for _, strategy in helpers.each_strategy() do
proxy_server_ssl_verify = proxy_opts.proxy_server_ssl_verify,
lua_ssl_trusted_certificate = proxy_opts.lua_ssl_trusted_certificate,

cluster_rpc = rpc,
cluster_incremental_sync = inc_sync,

-- this is unused, but required for the template to include a stream {} block
Expand Down

0 comments on commit a0f954b

Please sign in to comment.