Merge pull request #9803 from sstrigler/main-v4.4
feat: support HAProxy protocol for mgmt API
This commit is contained in:
commit
6e66d52d31
|
@ -90,6 +90,11 @@
|
|||
{datatype, {enum, [true, false]}}
|
||||
]}.
|
||||
|
||||
{mapping, "management.listener.http.proxy_header", "emqx_management.listeners", [
|
||||
{default, false},
|
||||
{datatype, {enum, [true, false]}}
|
||||
]}.
|
||||
|
||||
{mapping, "management.listener.https", "emqx_management.listeners", [
|
||||
{datatype, [integer, ip]}
|
||||
]}.
|
||||
|
@ -186,6 +191,11 @@
|
|||
{datatype, {enum, [true, false]}}
|
||||
]}.
|
||||
|
||||
{mapping, "management.listener.https.proxy_header", "emqx_management.listeners", [
|
||||
{default, false},
|
||||
{datatype, {enum, [true, false]}}
|
||||
]}.
|
||||
|
||||
{translation, "emqx_management.application", fun(Conf) ->
|
||||
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
||||
Opts = fun(Prefix) ->
|
||||
|
@ -202,7 +212,9 @@ end}.
|
|||
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
||||
Opts = fun(Prefix) ->
|
||||
Filter([{num_acceptors, cuttlefish:conf_get(Prefix ++ ".acceptors", Conf)},
|
||||
{max_connections, cuttlefish:conf_get(Prefix ++ ".max_clients", Conf)}])
|
||||
{max_connections, cuttlefish:conf_get(Prefix ++ ".max_clients", Conf)},
|
||||
{proxy_header, cuttlefish:conf_get(Prefix ++ ".proxy_header", Conf)}
|
||||
])
|
||||
end,
|
||||
TcpOpts = fun(Prefix) ->
|
||||
Filter([{backlog, cuttlefish:conf_get(Prefix ++ ".backlog", Conf, undefined)},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_management,
|
||||
[{description, "EMQ X Management API and CLI"},
|
||||
{vsn, "4.4.12"}, % strict semver, bump manually!
|
||||
{vsn, "4.4.13"}, % strict semver, bump manually!
|
||||
{modules, []},
|
||||
{registered, [emqx_management_sup]},
|
||||
{applications, [kernel,stdlib,emqx_plugin_libs,minirest]},
|
||||
|
|
|
@ -52,12 +52,12 @@ stop_listeners() ->
|
|||
start_listener({Proto, Port, Options}) when Proto == http ->
|
||||
Dispatch = [{"/status", emqx_mgmt_http, []},
|
||||
{"/api/v4/[...]", minirest, http_handlers()}],
|
||||
minirest:start_http(listener_name(Proto), ranch_opts(Port, Options), Dispatch);
|
||||
minirest:start_http(listener_name(Proto), ranch_opts(Port, Options), Dispatch, proto_opts(Options));
|
||||
|
||||
start_listener({Proto, Port, Options}) when Proto == https ->
|
||||
Dispatch = [{"/status", emqx_mgmt_http, []},
|
||||
{"/api/v4/[...]", minirest, http_handlers()}],
|
||||
minirest:start_https(listener_name(Proto), ranch_opts(Port, Options), Dispatch).
|
||||
minirest:start_https(listener_name(Proto), ranch_opts(Port, Options), Dispatch, proto_opts(Options)).
|
||||
|
||||
ranch_opts(Port, Options0) ->
|
||||
NumAcceptors = proplists:get_value(num_acceptors, Options0, 4),
|
||||
|
@ -68,6 +68,7 @@ ranch_opts(Port, Options0) ->
|
|||
({inet6, false}, Acc) -> Acc;
|
||||
({ipv6_v6only, true}, Acc) -> [{ipv6_v6only, true} | Acc];
|
||||
({ipv6_v6only, false}, Acc) -> Acc;
|
||||
({proxy_header, _}, Acc) -> Acc;
|
||||
({K, V}, Acc)->
|
||||
[{K, V} | Acc]
|
||||
end, [], Options0),
|
||||
|
@ -77,6 +78,9 @@ ranch_opts(Port, Options0) ->
|
|||
socket_opts => [{port, Port} | Options]},
|
||||
Res.
|
||||
|
||||
proto_opts(Options) ->
|
||||
maps:with([proxy_header], maps:from_list(Options)).
|
||||
|
||||
stop_listener({Proto, Port, _}) ->
|
||||
io:format("Stop http:management listener on ~s successfully.~n",[format(Port)]),
|
||||
minirest:stop_http(listener_name(Proto)).
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# v4.4.15
|
||||
|
||||
## Enhancements
|
||||
|
||||
- Support HAProxy protocol for dashboard API [9803](https://github.com/emqx/emqx/pull/9803).
|
|
@ -0,0 +1,5 @@
|
|||
# v4.4.15
|
||||
|
||||
## 增强
|
||||
|
||||
- 现在 dashboard 增加了对 `HAProxy` 协议的支持 [9803](https://github.com/emqx/emqx/pull/9803)。
|
|
@ -51,7 +51,7 @@
|
|||
, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.8.1.11"}}}
|
||||
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "3.0.1"}}}
|
||||
, {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.3.6"}}}
|
||||
, {minirest, {git, "https://github.com/emqx/minirest", {tag, "0.3.10"}}}
|
||||
, {minirest, {git, "https://github.com/emqx/minirest", {tag, "0.3.11"}}}
|
||||
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}}
|
||||
, {replayq, {git, "https://github.com/emqx/replayq", {tag, "0.3.4"}}}
|
||||
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
|
||||
|
|
Loading…
Reference in New Issue