Using ws:// while on https:// (mixed content)

CodingKiwi picture CodingKiwi · May 3, 2017 · Viewed 7k times · Source

I have a html5 page with

var connection = new WebSocket('ws://foo.bar:8888');

But I get an error

Mixed Content: The page at 'https://foo.bar/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://foo.bar:8888/'. This request has been blocked; this endpoint must be available over WSS.

I understand that, but I can't serve a Secure Websocket. Is there any way to make this work, except starting chrome with --allow-running-insecure-content or something like that, where the user has to do something?

Thanks!

Answer

CodingKiwi picture CodingKiwi · Dec 6, 2017

So months later I can say: If you can serve the page via https somewhere on your server there are certificate and chain files, use these to serve a wss