如何从 docker 容器通过 traefik 发布 websocket
How to publish websocket through traefik from docker container
我的 docker 集群中有 traefik 运行,为几个网站做 https 代理,这部分工作正常。
问题是我有一个容器只发布了一个 WSS (mosquitto),用于我的家庭自动化设置,我无法让它工作。
在我的自动化堆栈 yml 文件中,我有以下 mosquitto 节,根据我在各个页面上阅读的内容,我只需要将 HTTPS 指定为协议,因为它也涵盖 WSS
mqtt:
deploy:
restart_policy:
condition: any
delay: 5s
max_attempts: 3
window: 120s
placement:
constraints:
- node.labels.mysensors==yes
replicas: 1
labels:
- traefik.frontend.rule=Host:mqtt.mydomain.com
- traefik.port=9001
- traefik.docker.network=traefik-public
- traefik.enable=true
- traefik.redirectorservice.frontend.entryPoints=http
- traefik.redirectorservice.frontend.redirect.entryPoint=https
- traefik.frontend.whiteList.sourceRange=192.168.0.0/16
- traefik.tags=traefik-public
- traefik.webservice.frontend.entryPoints=https
ports:
- 1883:1883
networks:
- homeautomation
- traefik-public
volumes:
- /opt/mosquitto:/mosquitto
image: "eclipse-mosquitto:1.4.12"
在我的 Traefik 仪表板中,我只看到暴露的其他 (https) 服务后端,而不是这个 WSS 后端。想知道我的配置中缺少什么。
添加标签:
- traefik.backend.loadbalancer.stickiness: "true"
这将允许支持 wss 连接
我的 docker 集群中有 traefik 运行,为几个网站做 https 代理,这部分工作正常。
问题是我有一个容器只发布了一个 WSS (mosquitto),用于我的家庭自动化设置,我无法让它工作。
在我的自动化堆栈 yml 文件中,我有以下 mosquitto 节,根据我在各个页面上阅读的内容,我只需要将 HTTPS 指定为协议,因为它也涵盖 WSS
mqtt:
deploy:
restart_policy:
condition: any
delay: 5s
max_attempts: 3
window: 120s
placement:
constraints:
- node.labels.mysensors==yes
replicas: 1
labels:
- traefik.frontend.rule=Host:mqtt.mydomain.com
- traefik.port=9001
- traefik.docker.network=traefik-public
- traefik.enable=true
- traefik.redirectorservice.frontend.entryPoints=http
- traefik.redirectorservice.frontend.redirect.entryPoint=https
- traefik.frontend.whiteList.sourceRange=192.168.0.0/16
- traefik.tags=traefik-public
- traefik.webservice.frontend.entryPoints=https
ports:
- 1883:1883
networks:
- homeautomation
- traefik-public
volumes:
- /opt/mosquitto:/mosquitto
image: "eclipse-mosquitto:1.4.12"
在我的 Traefik 仪表板中,我只看到暴露的其他 (https) 服务后端,而不是这个 WSS 后端。想知道我的配置中缺少什么。
添加标签:
- traefik.backend.loadbalancer.stickiness: "true"
这将允许支持 wss 连接