如何从Docker容器通过Traefik发布Websocket

时间:2019-04-06 09:00:13

标签: traefik

我的docker swarm中运行着traefik,为多个网站进行https代理,这部分工作正常。

问题是我有一个只发布WSS(蚊子)的容器用于我的家庭自动化设置,而我无法使其工作。

在我的自动化堆栈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后端。.想知道我的配置中缺少什么。

1 个答案:

答案 0 :(得分:0)

添加标签

- traefik.backend.loadbalancer.stickiness: "true"

这将允许支持wss连接