5

I'm using Nginx + flask-socketio + aws elb and when the URL is loaded on https I'm getting the following error message which is something related to the Nginx and socket, please help on this,

socket.io.min.js:2 Mixed Content: The page at 'https://localhost/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost/socket.io/1/?t=1477375737508'. This request has been blocked; the content must be served over HTTPS.d.handshake @ socket.io.min.js:2
socket.io.min.js:2 XMLHttpRequest cannot load http://localhost/socket.io/1/?t=1477375737508. Failed to start loading.
IAmHomes
  • 513
  • 2
  • 11
  • 20

2 Answers2

4

Take a look into your .js file, make sure that you are using the right ajax URL (//your_site.com/handler, instead of http://your_site.com/handler), for instance:

$.ajax({
url:'//your_site.com/handler',dataType:'json',type:'get',
success: function(data){...},
complete:function(xhr, textStatus){...}
});
  • 2
    actually i overlooked that in my js file, all the while i was hitting the bush. Alow now i'm getting "WebSocket connection to 'ws://example.com/socket.io/1/websocket/654646646' failed: Error during WebSocket handshake: Unexpected response code: 500" – IAmHomes Oct 25 '16 at 18:32
  • 1
    Maybe these links can help: [Link 1](https://github.com/websocket-rails/websocket-rails/issues/378#issuecomment-170352798) [Link 2](https://github.com/websocket-rails/websocket-rails/issues/211#issuecomment-57744925) –  Oct 25 '16 at 18:43
0

Mixed Content is a security policy employed by current browsers, and its goal is to prevent leaking information fetched over "secure" HTTPS to non-secure contexts. Therefore, a site served with HTTPS must use HTTPS or other TLS-enabled protocols to fetch content.

The URI prefix for Websockets over TLS is wss, and for plain Websockets ws. At least Chromium and Firefox consider https+ws mixed content, and deny such setting - therefore wss should be used as the URI prefix in secure/HTTPS contexts instead of ws.

borellini
  • 365
  • 5
  • 13