emq集群配置nginx做负载均衡
创建 EMQ X 节点集群
emqx 集群搭建
例如:
节点 | IP 地址 |
---|---|
emqx@192.168.1.17 | 192.168.1.17 |
emqx@192.168.1.18 | 192.168.1.18 |
emqx@192.168.1.19 | 192.168.1.19 |
配置 /etc/nginx/nginx.conf
mqtt集群搭建并使用nginx做负载均衡_亲测得结论
示例:文章来源:https://www.toymoban.com/news/detail-743916.html
vim /etc/nginx/nginx.conf
http {
}
#在http外添加如下配置
stream {
upstream stream_backend {
zone tcp_servers 64k;
hash $remote_addr;
server 192.168.1.17:1883 max_fails=2 fail_timeout=30s;
server 192.168.1.18:1883 max_fails=2 fail_timeout=30s;
server 192.168.1.19:1883 max_fails=2 fail_timeout=30s;
}
server {
listen 8883 ssl;
status_zone tcp_server;
proxy_pass stream_backend;
proxy_buffer_size 4k;
ssl_handshake_timeout 15s;
ssl_certificate /etc/emqx/certs/cert.pem;
ssl_certificate_key /etc/emqx/certs/key.pem;
}
}
参考链接:
https://docs.emqx.cn/enterprise/v4.3/tutorial/deploy.html#%E7%A7%81%E6%9C%89%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2文章来源地址https://www.toymoban.com/news/detail-743916.html
到了这里,关于emq集群配置nginx做负载均衡的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!