Support for advertising different hostname for TLS stream connections

Use case: Allow plain connections over one (internal IP), and TLS
connections over another IP (eg. internet routable IP). Without this
patch a cluster can only support access over one or the other IP, not
both.

(cherry picked from commit b9e6aad035)
This commit is contained in:
Carl Hörberg 2021-09-27 22:52:36 +02:00 committed by Arnaud Cogoluègnes
parent f932c3e0bc
commit 52791c677b
No known key found for this signature in database
GPG Key ID: D5C8C4DFAD43AFA8
4 changed files with 30 additions and 3 deletions

View File

@ -193,6 +193,15 @@ fun(Conf) ->
list_to_binary(cuttlefish:conf_get("stream.advertised_host", Conf))
end}.
{mapping, "stream.advertised_tls_host", "rabbitmq_stream.advertised_tls_host", [
{datatype, string}
]}.
{translation, "rabbitmq_stream.advertised_tls_host",
fun(Conf) ->
list_to_binary(cuttlefish:conf_get("stream.advertised_tls_host", Conf))
end}.
{mapping, "stream.advertised_port", "rabbitmq_stream.advertised_port", [
{datatype, integer}
]}.

View File

@ -20,6 +20,7 @@
-export([start/2,
host/0,
tls_host/0,
port/0,
tls_port/0,
kill_connection/1]).
@ -44,6 +45,15 @@ start(_Type, _Args) ->
{queue_type, ?STREAM_QUEUE_TYPE}]),
rabbit_stream_sup:start_link().
tls_host() ->
case application:get_env(rabbitmq_stream, advertised_tls_host, undefined)
of
undefined ->
hostname_from_node();
Host ->
rabbit_data_coercion:to_binary(Host)
end.
host() ->
case application:get_env(rabbitmq_stream, advertised_host, undefined)
of

View File

@ -1374,7 +1374,13 @@ handle_frame_pre_auth(Transport,
VirtualHost,
{socket, S},
#{}),
AdvertisedHost = rabbit_stream:host(),
AdvertisedHost =
case TransportLayer of
tcp ->
rabbit_stream:host();
ssl ->
rabbit_stream:tls_host()
end,
AdvertisedPort =
case TransportLayer of
tcp ->

View File

@ -54,9 +54,11 @@
[rabbitmq_stream]},
{advertised_host_port,
"stream.advertised_host = some-host
stream.advertised_tls_host = some-other-host
stream.advertised_port = 5556
stream.advertised_tls_port = 5553",
[{rabbitmq_stream,[{advertised_host, <<"some-host">>},
{advertised_tls_host, <<"some-other-host">>},
{advertised_port, 5556},
{advertised_tls_port, 5553}]}],
[rabbitmq_stream]},