Ubuntu部署EMQ与调试

最近的项目在做IOT:
硬件上云篇

这是服务器篇:
1.使用的协议是 MQTT,
2.采用的实现方案是国产开源EMQ代理器
下面简单记录一下emq服务端部署需要注意的细节:
1.下载解压EMQ

wget http://emqtt.com/downloads/2318/ubuntu16_04

2.解压并进入目录

unzip emqtt && cd emqtt

3.启动emq

./bin/emqttd start

4.查看状态

./bin/emqttd_ctl status

5.控制台地址是127.0.0.1:18083


image.png

6.ngxin端口转发到80地址,ngxin配置文件

server
{
        listen 80;
        server_name emqtt.your-domain.com ; #你的子域名

        location /
        {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:18083;
        }

        location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$
        {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://127.0.0.1:18083;

        }

        access_log off;
}

7.部署在阿里云上有一个细节需要注意的就是
端口的开启,

8.查看端口开启

netstat  -an

查看防火墙开启端口

#阿里云Ubuntu基本上使用iptables,所以先找到iptables
sudo whereis iptables
#列出端口
/sbin/iptables -L

如图


image.png

9.配置文件在如图 /etc/iptables/rules中
在其中添加需要开启的端口


image.png

10.保存文件

/sbin/iptables save

11.nginx域名转发一下端口

12.重启nginx服务

13.浏览器访问

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容