# Websocket does not upgrade ws to wss

**URL:** https://community.traefik.io/t/websocket-does-not-upgrade-ws-to-wss/12017
**Category:** Traefik v2
**Tags:** docker-swarm, letsencrypt-acme, middleware
**Created:** [October 7, 2021, 2:12am UTC](https://community.traefik.io/t/websocket-does-not-upgrade-ws-to-wss/12017 "2021-10-07T02:12:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![groliveira18](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/groliveira18/32/4375_2.png) [@groliveira18](https://community.traefik.io/u/groliveira18)
#### Post date: [October 7, 2021, 2:12am UTC](https://community.traefik.io/t/websocket-does-not-upgrade-ws-to-wss/12017/1 "2021-10-07T02:12:19Z")

</div>

Everyone, hello!

I'm struggling to implement a backend that uses websocket in the application.

When using apache, it was enough to do a

> Header always set Content-Security-Policy "upgrade-insecure-requests;"

that worked my Websocket perfectly.

Currently on Traefk I'm having mixed content issue between the browser calling WSS while the answer comes as WS.

I've tried the following ways to solve it without success.  
`- traefik.http.middlewares.sslheader.headers.contentSecurityPolicy=upgrade-insecure-requests`  
`- traefik.http.middlewares.sslheader.headers.customResponseHeaders.Content-Security-Policy=upgrade-insecure-requests`  
`- traefik.http.middlewares.sslheader.headers.customResponseHeaders.Content-Security-Policy-Report-Only=upgrade-insecure-requests`  
`- traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https`

> Mixed Content: The page at '[https://grecco.conexao.tec.br/open.do?sys=WEB](https://grecco.conexao.tec.br/open.do?sys=WEB)' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://grecco.conexao.tec.br/WS337693904'. This request has been blocked; this endpoint must be available over WSS.

---

<div class="post-metadata">

### Author: ![groliveira18](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/groliveira18/32/4375_2.png) [@groliveira18](https://community.traefik.io/u/groliveira18)
#### Post date: [October 7, 2021, 4:09am UTC](https://community.traefik.io/t/websocket-does-not-upgrade-ws-to-wss/12017/2 "2021-10-07T04:09:31Z")

</div>

> [@groliveira18](#):
>
> - traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https

Guys, the solution to the websocket problem is actually here, with two modifications.

The first: The middlewares must be created for safe route(443). I was using middlewares on the unsafe route(80).

The second: `- traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https,wss`

adding wss to the end.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)
#### Post date: [October 10, 2021, 4:09am UTC](https://community.traefik.io/t/websocket-does-not-upgrade-ws-to-wss/12017/3 "2021-10-10T04:09:45Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
