Websocket does not upgrade ws to wss

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' 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.

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.

2 Likes

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