-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clustering): hybrid forward proxy in https (#9773)
Add support of talk to an HTTP tunnel in https FTI-2996
- Loading branch information
Showing
9 changed files
with
150 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,12 @@ local fixtures = { | |
forward_proxy = [[ | ||
server { | ||
listen 16797; | ||
listen 16799 ssl; | ||
listen [::]:16799 ssl; | ||
ssl_certificate ../spec/fixtures/kong_spec.crt; | ||
ssl_certificate_key ../spec/fixtures/kong_spec.key; | ||
error_log logs/proxy.log debug; | ||
content_by_lua_block { | ||
|
@@ -17,29 +23,57 @@ local fixtures = { | |
server { | ||
listen 16796; | ||
listen 16798 ssl; | ||
listen [::]:16798 ssl; | ||
ssl_certificate ../spec/fixtures/kong_spec.crt; | ||
ssl_certificate_key ../spec/fixtures/kong_spec.key; | ||
error_log logs/proxy_auth.log debug; | ||
content_by_lua_block { | ||
require("spec.fixtures.forward-proxy-server").connect({ | ||
basic_auth = ngx.encode_base64("test:konghq"), | ||
}) | ||
} | ||
} | ||
]], | ||
}, | ||
} | ||
|
||
|
||
local auth_confgs = { | ||
["auth off"] = "http://127.0.0.1:16797", | ||
["auth on"] = "http://test:[email protected]:16796", | ||
local proxy_configs = { | ||
["https off auth off"] = { | ||
proxy_server = "http://127.0.0.1:16797", | ||
proxy_server_ssl_verify = "off", | ||
}, | ||
["https off auth on"] = { | ||
proxy_server = "http://test:[email protected]:16796", | ||
proxy_server_ssl_verify = "off", | ||
}, | ||
["https on auth off"] = { | ||
proxy_server = "https://127.0.0.1:16799", | ||
proxy_server_ssl_verify = "off", | ||
}, | ||
["https on auth on"] = { | ||
proxy_server = "https://test:[email protected]:16798", | ||
proxy_server_ssl_verify = "off", | ||
}, | ||
["https on auth off verify on"] = { | ||
proxy_server = "https://localhost:16799", -- use `localhost` to match CN of cert | ||
proxy_server_ssl_verify = "on", | ||
lua_ssl_trusted_certificate = "spec/fixtures/kong_spec.crt", | ||
}, | ||
} | ||
|
||
-- Note: this test suite will become flakky if KONG_TEST_DONT_CLEAN | ||
-- if existing lmdb data is set, the service/route exists and | ||
-- test run too fast before the proxy connection is established | ||
|
||
for _, strategy in helpers.each_strategy() do | ||
for auth_desc, proxy_url in pairs(auth_confgs) do | ||
describe("CP/DP sync through proxy (" .. auth_desc .. ") works with #" .. strategy .. " backend", function() | ||
for proxy_desc, proxy_opts in pairs(proxy_configs) do | ||
describe("CP/DP sync through proxy (" .. proxy_desc .. ") works with #" .. strategy .. " backend", function() | ||
lazy_setup(function() | ||
helpers.get_db_utils(strategy) -- runs migrations | ||
|
||
|
@@ -67,7 +101,9 @@ for _, strategy in helpers.each_strategy() do | |
nginx_conf = "spec/fixtures/custom_nginx.template", | ||
|
||
cluster_use_proxy = "on", | ||
proxy_server = proxy_url, | ||
proxy_server = proxy_opts.proxy_server, | ||
proxy_server_ssl_verify = proxy_opts.proxy_server_ssl_verify, | ||
lua_ssl_trusted_certificate = proxy_opts.lua_ssl_trusted_certificate, | ||
|
||
-- this is unused, but required for the the template to include a stream {} block | ||
stream_listen = "0.0.0.0:5555", | ||
|
@@ -114,18 +150,20 @@ for _, strategy in helpers.each_strategy() do | |
end | ||
end, 10) | ||
|
||
local auth_on = string.match(proxy_desc, "auth on") | ||
|
||
-- ensure this goes through proxy | ||
local path = pl_path.join("servroot2", "logs", | ||
(auth_desc == "auth on") and "proxy_auth.log" or "proxy.log") | ||
auth_on and "proxy_auth.log" or "proxy.log") | ||
local contents = pl_file.read(path) | ||
assert.matches("CONNECT 127.0.0.1:9005", contents) | ||
|
||
if auth_desc == "auth on" then | ||
if auth_on then | ||
assert.matches("accepted basic proxy%-authorization", contents) | ||
end | ||
end) | ||
end) | ||
end) | ||
|
||
end -- auth configs | ||
end -- proxy configs | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters