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


Ubuntu部署EMQ与调试_第1张图片
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

如图


Ubuntu部署EMQ与调试_第2张图片
image.png

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


Ubuntu部署EMQ与调试_第3张图片
image.png

10.保存文件

/sbin/iptables save

11.nginx域名转发一下端口

12.重启nginx服务

13.浏览器访问

你可能感兴趣的:(Ubuntu部署EMQ与调试)