LearnBoost/socket.io — pull request #622 by mattrobenolt (2011-11-03 04:49:32+00:00)
Title: Location mismatch in Safari behind proxy

First of all, I've seen a bunch of random discussions around this issue, but I couldn't find any definitive reasons for why this is like this.

Second, I'm not a Websocket expert.

With that in mind, my patch is mostly geared towards making sure that the location response is of the same protocol as the request origin. This will be a mismatch when proxying through stunnel or nginx. The proxy terminates the original wss connection and proxies it back as a normal ws. Safari decides to complain when the location spit back is ws and it's expecting wss.

This patch just makes sure to match the ws(s) with the http(s) of the origin. If there's a reason why that shouldn't be done like this, I'm sorry. I'm tired. In my basic tests, this works when accessing over http and https in Firefox and Safari. I didn't test IE at all since I don't own a Windows machine.