# Secured WebSocket WSS

**URL:** <https://community.traefik.io/t/secured-websocket-wss/15404>\
**Category:** Traefik v2\
**Tags:** letsencrypt-acme\
**Created:** [August 11, 2022, 7:02pm UTC](https://community.traefik.io/t/secured-websocket-wss/15404 "2022-08-11T19:02:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonasjonny](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jonasjonny](https://community.traefik.io/u/jonasjonny)\
**Post date:** [August 11, 2022, 7:02pm UTC](https://community.traefik.io/t/secured-websocket-wss/15404/1 "2022-08-11T19:02:56Z")

</div>

Hello,  
thank you for a great Traefik.  
I have a problem with WSS configuration.  
I tried everything what I found here or on stackoverflow - nothing works.

> My static yml configuration:

```auto
serversTransport:
  insecureSkipVerify: true

certificatesResolvers:
  le:
    acme:
      email: <EMAIL>
      storage: /etc/<NAME>.json
      caServer: 'https://acme-v02.api.letsencrypt.org/directory'
      httpChallenge:
        entryPoint: http
      tlsChallenge: {}

entryPoints:
  http:
    address: ':80'
  https:
    address: ':443'
  http4500:
    address: ':4500'
  https4501:
    address: ':4501'
    http:
      tls:
        certResolver: le
      redirections:
        entryPoint:
          scheme: https

providers:
  file:
    directory: "/etc/traefik.d"
    watch: true

```

> When I use "`http4500`", WS is working.

```auto
http:
  routers:
    abc-app:
      entryPoints:
        - "http"
      rule: "Host(`<ABC-APP-URL>`)"
      service: abc-app-service
    abc-ws:
      entryPoints:
        - "http4500"
      rule: "Host(`<ABC-APP-URL>`) && PathPrefix(`/subscriptions`)"
      service: abc-ws-service

  services:
    abc-app-service:
      loadBalancer:
        servers:
          - url: "http://<SERVER-URL>:30001"
    abc-ws-service:
      loadBalancer:
        servers:
          - url: "http://<SERVER-URL>:30002"

```

But I cannot make WSS work through "`http4501`" but Let's Encrypt certificate for domain is working OK through "`https`".

```auto
http:
  routers:
    abc-app:
      entryPoints:
        - "http"
        - "https"
      rule: "Host(`<ABC-APP-URL>`) || Host(`www.<ABC-APP-URL>`)"
      middlewares:
        - https-redirect
      service: abc-app-service
      tls:
        certResolver: "le"
        domains:
          - main: "<ABC-APP-URL>"
            sans:
              - "www.<ABC-APP-URL>"
    abc-ws:
      entryPoints:
        - "https4501"
      rule: "Host(`<ABC-APP-URL>`) && PathPrefix(`/subscriptions`)"
      middlewares:
        - sslheader
      service: abc-ws-service
      tls:
        certResolver: "le"
        domains:
          - main: "<ABC-APP-URL>"
            sans:
              - "www.<ABC-APP-URL>"

  middlewares:
    sslheader:
      headers:
        customRequestHeaders:
          X-Forwarded-Proto: https
    https-redirect:
      redirectScheme:
        scheme: https
        permanent: true

  services:
    abc-app-service:
      loadBalancer:
        servers:
          - url: "http://<SERVER-URL>:30004"
    abc-ws-service:
      loadBalancer:
        servers:
          - url: "http://<SERVER-URL>:30005"

```

I also tried middleware "wsstest"

```auto
    wsstest:
      redirectScheme:
        port: "443"
      headers:
        customRequestHeaders:
          X-Forwarded-Proto: https

```

and/or "socket"

```auto
    socket:
      headers:
        forceSTSHeader: true
        STSSeconds: 315360000
        STSIncludeSubdomains: true
        STSPreload: true
        browserXSSFilter: true
        contentTypeNosniff: true
        frameDeny: true
        sslForceHost: true
        sslRedirect: true
        customResponseHeaders:
          X-Robots-Tag: "none"
          X-Script-Name: "test"
        customFrameOptionsValue: "SAMEORIGIN"

```

Both ports on server `<SERVER-URL>` (:30002, :30005) are accessible.

```auto
wscat -c ws://<ABC-APP-URL>:4500/subscriptions
Connected 

```

```auto
wscat -c wss://<ABC-APP-URL>/subscriptions
error: certificate has expired

```

```auto
wscat -c wss://<ABC-APP-URL>:4501/subscriptions
error: connect ETIMEDOUT xxx.xxx.xxx.xxx:4501

```

And in Chrome: `WebSocket is closed before the connection is established`.

Is there something missing?  
I am trying to figure it out for 3 days but with no luck ☹ .

Can anyone please help?

---

<div class="post-metadata">

**Author:** ![jonasjonny](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jonasjonny](https://community.traefik.io/u/jonasjonny)\
**Post date:** [August 23, 2022, 2:26pm UTC](https://community.traefik.io/t/secured-websocket-wss/15404/2 "2022-08-23T14:26:48Z")

</div>

After all I used basic "`https`" as EntryPoint and WSS is working ✅.  
Port `443`.  
Also I don't need any middleware.

```auto
    abc-ws:
      entryPoints:
        - "https"
      rule: "Host(`<ABC-APP-URL>`) && PathPrefix(`/subscriptions`)"
      service: abc-ws-service
      tls:
        certResolver: "le"
        domains:
          - main: "<ABC-APP-URL>/subscriptions"
            sans:
              - "www.<ABC-APP-URL>/subscriptions"

```
