MQTT服务器搭建之域名和nginx配置

nginx配置文件

//配置wss

upstream mqttws
{
    server 0.0.0.0:9001;
}
location /mqtt 
{
    proxy_pass http://mqttws; 
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $remote_addr;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade          $http_upgrade;
    proxy_set_header   Connection "upgrade";
    proxy_set_header   Sec-WebSocket-Protocol mqtt;
}
即使用mqtt.xxx.com/mqtt,并通过wss方式可连接到MQTT服务器

本文链接:

https://www.zaigie.com/archives/363/