title: Docker Traefik fails to route websocket
body: <p>I have several micro-services running as docker containers. All web services work fine and route correctly.</p>
  <p>The only issue is the websocket service.
  The websocket service itself is using python websockets and has it's own TLS certificates.</p>
  <p>Trying to access the websocket with <code>wss://websocket.localhost</code> fails, in the setup below it doesn't find the page at all.
  In my previous configurations, it results in the <strong>Bad Gateway</strong> error.</p>
  <p>Apparently <code>traefik</code> comes out of the box working with websockets with no additional configurations.</p>
  <p>This doesn't seem to be the case. Any pointers?</p>
  <p>The websocket connection works without docker or traefik involved, so I ruled that issue out.
  Any help on this would be extremely appreciated.</p>
  <h2><code>docker-compose.yml</code></h2>
  <pre class="lang-yaml prettyprint-override"><code>version: &quot;3.7&quot;
  
  networks:
    web:
      external: true
    internal:
      external: false
  
  volumes:
    mysql_data:
  
  services:
    traefik:
      image: traefik:v2.2.1
      container_name: traefik
      restart: always
      ports:
        - &quot;80:80&quot;
        - &quot;443:443&quot;
      expose:
        - 8080
      environment:
        - /var/run/docker.sock:/var/run/docker.sock
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - ./config/:/config
        - ./traefik.yml:/traefik.yml
      networks:
        - web
        - internal
      labels:
        - traefik.http.routers.traefik.tls=true
        - traefik.http.routers.traefik.entrypoints=secure
        - traefik.http.routers.traefik.rule=Host(`traefik.localhost`)
        - traefik.http.routers.traefik.service=api@internal
  
    dozzle:
      image: amir20/dozzle:latest
      container_name: dozzle
      restart: always
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
      expose:
        - 8080
      labels:
        - traefik.http.routers.dozzle.tls=true
        - traefik.http.routers.dozzle.entrypoints=secure
        - traefik.http.routers.dozzle.rule=Host(`dozzle.localhost`) || Host(`logs.localhost`)
      networks:
        - internal
  
    db:
      image: mysql:latest
      container_name: db
      environment:
        MYSQL_ROOT_PASSWORD: ########
      restart: always
      healthcheck:
        test: &quot;exit 0&quot;
      command: --default-authentication-plugin=mysql_native_password
      ports:
        - '3306:3306'
      volumes:
        - mysql_data:/var/lib/mysql
      networks:
        - internal
  
    websocket:
      image: local-websocket-image
      container_name: websocket-stage
      restart: on-failure
      command: python server.py
      depends_on:
        db:
          condition: service_healthy
      expose:
        - 8080
      networks:
        - web
        - internal
      environment:
        - PATH_TO_CONFIG=/src/setup.cfg
      volumes:
        - ${PWD}/docker-config:/src
        - ${PWD}/config/certs/socket:/var
      labels:
        - traefik.http.routers.core-socket-stage-router.tls=true
        - traefik.http.routers.core-socket-stage-router.entrypoints=secure
        - traefik.http.routers.core-socket-stage-router.rule=Host(`websocket.localhost`)
  </code></pre>
  <h2><code>traefik.yml</code></h2>
  <pre class="lang-yaml prettyprint-override"><code>entryPoints:
    insecure:
      address: :80
      http:
        redirections:
          entryPoint:
            to: secure
            scheme: https
    secure:
      address: :443
  
  log:
    level: INFO
   
  accessLog:
    filePath: &quot;traefik-access.log&quot;
    bufferingSize: 100
  
  api:
    dashboard: true
    insecure: true
  
  ping: {}
  
  providers:
    file:
      filename: /config/dynamic.yml # traefik dynamic configuration
      watch: true                   # everytime it changes, it will be reloaded 
    docker:
      endpoint: &quot;unix:///var/run/docker.sock&quot;
      exposedByDefault: true
  </code></pre>
  <h2>config</h2>
  <pre class="lang-yaml prettyprint-override"><code>tls:
    stores:
      default:
        defaultCertificate:
          certFile: cert.crt
          keyFile: key.key
  
    certificates:
      - certFile: crt.crt
        keyFile: key.key
        stores:
          - default
   
    domains:
      - main: &quot;localhost&quot;
  </code></pre>