小编Luc*_*ifi的帖子

为 MQTT 配置 Nginx 反向代理

我正在尝试设置一个反向代理,将 localhost:8081 解析为安装在另一台计算机上的代理。我的 Nginx 配置文件是:

worker_processes  1;

events {
    worker_connections 1024;
}

server {
    listen 8081;
    server_name localhost;

    location / {
        proxy_pass tcp://192.168.1.177:1883;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用以下命令连接到代理(从我配置 Nginx 的机器)时

 mosquitto_sub -h localhost -p 8081 -t "stat/tasmota_8231A8/POWER1"
Run Code Online (Sandbox Code Playgroud)

我收到错误连接被拒绝。

编辑:Mosquitto 代理配置:

persistence true
persistence_location /var/lib/mosquitto/

include_dir /etc/mosquitto/conf.d

listener 1883
allow_anonymous true
Run Code Online (Sandbox Code Playgroud)

编辑我尝试使用 nginx worker_processes 1; 的配置文件

events {
    worker_connections 1024;
}
stream {
   listen 8081;
   proxy_pass 192.168.1.77:1883;
} 
Run Code Online (Sandbox Code Playgroud)

nginx mqtt nginx-reverse-proxy nginx-config

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

mqtt ×1

nginx ×1

nginx-config ×1

nginx-reverse-proxy ×1