I have an Issue to Acces MQTT mosquito Broker over an Nginx Container This is My docker撰写:
`version: '3.8'
services:
mqtt-broker:
image: eclipse-mosquitto:1.6.13
container_name: mqtt-broker
user: "1000:1000"
ports:
- 1883:1883
- 9001:9001
volumes:
- ./config/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf.:ro
mqtt-nginx:
image: nginx:latest
container_name: mqtt-nginx
ports:
- '1884:1884'
depends_on:
- mqtt-broker
volumes:
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro`
这是我的nginx.conf:
events {
worker_connections 1024;
}
stream {
server {
listen 1884;
proxy_pass 127.0.0.1:1883;
}
}
但是当我测试连接时:mosquitto_sub -h 127.0.0.1 -p 1884 -t mytopic
我得到一个网络协议错误:Error: A network protocol error occurred when communicating with the broker.
如何修复我的配置!!
1条答案
按热度按时间gt0wga4j1#
固定nginx配置:
在我的docker-compose中添加网络: