traefik - 如何通过 docker 容器中的 traefik 发布 websocket
问题描述
我在我的 docker swarm 中运行 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 连接
推荐阅读
- android - “Android Profiler”上的空请求正文
- python - 发送 Xml 请求
- javascript - JavaScript 正则表达式从样式 HTML 标记中提取文本
- python - Python - Pandas Dataframe 在导入时忽略 \
- ruby-on-rails - 在 Rails 中实现 OAuth 提供程序以与单个客户端应用程序一起使用
- javascript - IMG 中的变量
- javascript - Font-Awesome:我可以让图标可点击吗?
- html - 是否可以一次引用一个 svg 文件,然后多次使用它?
- excel - 如果为真,则创建一个列表并引用某个单元格
- android - 如何将 GridLayout 的子项的宽度设置为相等大小并使它们均匀分布?