Merge pull request #1476 from emqtt/ws-proxy
Fix issue #1335 - Forward real client IP using a reverse proxy for websocket
This commit is contained in:
commit
f810698d7e
|
@ -1084,6 +1084,10 @@ listener.ws.external.max_clients = 102400
|
||||||
## Value: ACL Rule
|
## Value: ACL Rule
|
||||||
listener.ws.external.access.1 = allow all
|
listener.ws.external.access.1 = allow all
|
||||||
|
|
||||||
|
## listener.ws.external.proxy_address_header = x-forwarded-for
|
||||||
|
|
||||||
|
## listener.ws.external.proxy_port_header = x-remote-port
|
||||||
|
|
||||||
## Enable the Proxy Protocol V1/2 if the EMQ cluster is deployed behind
|
## Enable the Proxy Protocol V1/2 if the EMQ cluster is deployed behind
|
||||||
## HAProxy or Nginx.
|
## HAProxy or Nginx.
|
||||||
##
|
##
|
||||||
|
@ -1200,6 +1204,10 @@ listener.wss.external.max_clients = 64
|
||||||
## Value: ACL Rule
|
## Value: ACL Rule
|
||||||
listener.wss.external.access.1 = allow all
|
listener.wss.external.access.1 = allow all
|
||||||
|
|
||||||
|
## listener.wss.external.proxy_address_header = x-forwarded-for
|
||||||
|
|
||||||
|
## listener.wss.external.proxy_port_header = x-remote-port
|
||||||
|
|
||||||
## Enable the Proxy Protocol V1/2 support.
|
## Enable the Proxy Protocol V1/2 support.
|
||||||
##
|
##
|
||||||
## See: listener.tcp.<name>.proxy_protocol
|
## See: listener.tcp.<name>.proxy_protocol
|
||||||
|
|
|
@ -1029,6 +1029,16 @@ end}.
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.proxy_port_header", "emqttd.listeners", [
|
||||||
|
{datatype, string},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.proxy_address_header", "emqttd.listeners", [
|
||||||
|
{datatype, string},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ws.$name.proxy_protocol", "emqttd.listeners", [
|
{mapping, "listener.ws.$name.proxy_protocol", "emqttd.listeners", [
|
||||||
{datatype, flag}
|
{datatype, flag}
|
||||||
]}.
|
]}.
|
||||||
|
@ -1115,6 +1125,16 @@ end}.
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.proxy_port_header", "emqttd.listeners", [
|
||||||
|
{datatype, string},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.proxy_address_header", "emqttd.listeners", [
|
||||||
|
{datatype, string},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.wss.$name.proxy_protocol", "emqttd.listeners", [
|
{mapping, "listener.wss.$name.proxy_protocol", "emqttd.listeners", [
|
||||||
{datatype, flag}
|
{datatype, flag}
|
||||||
]}.
|
]}.
|
||||||
|
@ -1244,7 +1264,9 @@ end}.
|
||||||
{proxy_protocol, cuttlefish:conf_get(Prefix ++ ".proxy_protocol", Conf, undefined)},
|
{proxy_protocol, cuttlefish:conf_get(Prefix ++ ".proxy_protocol", Conf, undefined)},
|
||||||
{proxy_protocol_timeout, cuttlefish:conf_get(Prefix ++ ".proxy_protocol_timeout", Conf, undefined)},
|
{proxy_protocol_timeout, cuttlefish:conf_get(Prefix ++ ".proxy_protocol_timeout", Conf, undefined)},
|
||||||
{mountpoint, MountPoint(cuttlefish:conf_get(Prefix ++ ".mountpoint", Conf, undefined))},
|
{mountpoint, MountPoint(cuttlefish:conf_get(Prefix ++ ".mountpoint", Conf, undefined))},
|
||||||
{peer_cert_as_username, cuttlefish:conf_get(Prefix ++ ".peer_cert_as_username", Conf, undefined)}])
|
{peer_cert_as_username, cuttlefish:conf_get(Prefix ++ ".peer_cert_as_username", Conf, undefined)},
|
||||||
|
{proxy_port_header, cuttlefish:conf_get(Prefix ++ ".proxy_port_header", Conf, undefined)},
|
||||||
|
{proxy_address_header, cuttlefish:conf_get(Prefix ++ ".proxy_address_header", Conf, undefined)}])
|
||||||
end,
|
end,
|
||||||
|
|
||||||
LisOpts = fun(Prefix) ->
|
LisOpts = fun(Prefix) ->
|
||||||
|
@ -1290,7 +1312,8 @@ end}.
|
||||||
undefined ->
|
undefined ->
|
||||||
[];
|
[];
|
||||||
ListenOn ->
|
ListenOn ->
|
||||||
[{Atom(Type), ListenOn, [{connopts, ConnOpts(Prefix)}, {sockopts, TcpOpts(Prefix)} | LisOpts(Prefix)]}]
|
[{Atom(Type), ListenOn, [{connopts, ConnOpts(Prefix)},
|
||||||
|
{sockopts, TcpOpts(Prefix)} | LisOpts(Prefix)]}]
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application,emqttd,
|
{application,emqttd,
|
||||||
[{description,"Erlang MQTT Broker"},
|
[{description,"Erlang MQTT Broker"},
|
||||||
{vsn,"2.3.3"},
|
{vsn,"2.3.4"},
|
||||||
{modules,[]},
|
{modules,[]},
|
||||||
{registered,[emqttd_sup]},
|
{registered,[emqttd_sup]},
|
||||||
{applications,[kernel,stdlib,gproc,lager,esockd,mochiweb,
|
{applications,[kernel,stdlib,gproc,lager,esockd,mochiweb,
|
||||||
|
|
Loading…
Reference in New Issue