/etc/mosquitto/mosquitto.conf
port 1883
listener 8883
cafile /www/server/nginx/conf/whmake.site_root.crt
certfile /www/server/nginx/conf/whmake.site_bundle.crt
keyfile /www/server/nginx/conf/whmake.site.key
listener 8083
protocol websockets
listener 8084
protocol websockets
cafile /www/server/nginx/conf/whmake.site_root.crt
certfile /www/server/nginx/conf/whmake.site_bundle.crt
keyfile /www/server/nginx/conf/whmake.site.key
nginx配置
location /mqtt {
proxy_redirect off;
proxy_pass https://127.0.0.1:8084; # 反向代理到 加密 WebSocket ws
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr; # 反向代理保留客户端地址
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
# WebSocket 额外请求头
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
}