TBowmo
TBowmo

Reputation: 141

How to publish websocket through traefik from docker container

I have traefik running in my docker swarm, doing https proxying for a couple of websites, this part is working fine.

The problem is that I have one container that only publishes a WSS (mosquitto), for my home automation setup, and I can't get it to work.

In my automation stack yml file I have the following stanza for mosquitto, from what I have read on various pages, I just need to specify HTTPS as a protocol, as it also covers 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"

In my Traefik dashboard, I only see the other (https) service backends exposed, and not this WSS one.. Wonder what I am missing in my configuration.

Upvotes: 1

Views: 2189

Answers (1)

promzeus
promzeus

Reputation: 302

Add in labels:

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

This will allow to support wss connections

Upvotes: 1

Related Questions