EMQX版本:5.1.4
操作系统:Windows Server 2022 Datacenter
使用以下Nginx配置负载均衡
EMQX
stream {
# emqx_dashboard
upstream stream_backend_emqx_dashboard {
zone tcp_servers 64k;
#hash $remote_addr;
server emqx.vikingx.top:18083 max_fails=2 fail_timeout=30s;
}
server {
listen 18084;
proxy_pass stream_backend_emqx_dashboard;
#proxy_protocol on;
proxy_buffer_size 4k;
ssl_handshake_timeout 15s;
ssl_certificate ssl/emqx.vikingx.top_bundle.crt;
ssl_certificate_key ssl/emqx.vikingx.top.key;
}
# emqx_tcp
upstream stream_backend_emqx_tcp {
zone tcp_servers 64k;
#hash $remote_addr;
server emqx.vikingx.top:1883 max_fails=2 fail_timeout=30s;
}
server {
listen 1884 ssl;
proxy_pass stream_backend_emqx_tcp;
proxy_protocol on;
proxy_buffer_size 4k;
ssl_handshake_timeout 15s;
ssl_certificate ssl/emqx.vikingx.top_bundle.crt;
ssl_certificate_key ssl/emqx.vikingx.top.key;
}
server {
listen 1885;
proxy_pass stream_backend_emqx_tcp;
proxy_protocol on;
proxy_buffer_size 4k;
}
# emqx_ws
upstream stream_backend_emqx_ws {
zone tcp_servers 64k;
#hash $remote_addr;
server emqx.vikingx.top:8083 max_fails=2 fail_timeout=30s;
}
server {
listen 8084 ssl;
proxy_pass stream_backend_emqx_ws;
proxy_protocol on;
proxy_buffer_size 4k;
ssl_handshake_timeout 15s;
ssl_certificate ssl/emqx.vikingx.top_bundle.crt;
ssl_certificate_key ssl/emqx.vikingx.top.key;
}
server {
listen 8085;
proxy_pass stream_backend_emqx_ws;
proxy_protocol on;
proxy_buffer_size 4k;
}
}
使用MQTTX连接时,mqtt://及mqtts://均可正常连接
而ws://及wss://均连不上
telnet emqx.vikingx.top 1883 1884 1885 8083 8084 8085均正常
emqx log: