问题
I have a website hosted on lighttpd, accessible at the "www" subdomain. I also have a chat server listening on port 8124 made with node.js and socket.io.
I want all client traffic to happen on port 80, by redirecting all requests to the "chat" subdomain to port 8124. So I enabled mod_proxy and in lighttpd.conf I added:
$HTTP["host"] == "chat.myserver.com" {
proxy.server = (
"" => ((
"host" => "78.128.79.192",
"port" => "8124"
))
)
}
On the client, when I connect to the websocket,
var socket = io.connect('http://chat.myserver.com');
I get the right messages from node.js:
debug - client authorized
info - handshake authorized 6067470561567883577
debug - setting request GET /socket.io/1/websocket/6067470561567883577
debug - set heartbeat interval for client 6067470561567883577
debug - client authorized for
debug - websocket writing 1::
But the browser gives an error:
Firefox can't connect to server ws://chat.myserver.com/socket.io/1/websocket/6067470561567883577
Of course, everything works correctly if I connect directly to the port 8124:
var socket = io.connect('http://www.myserver.com:8124');
But, as I said, I would like all client traffic to be on port 80. Is it possibile?
回答1:
mod_proxy is known to be not compatible with websockets.
HAProxy is compatible (I haven't tested it myself but here's an article on its configuration for websockets).
来源:https://stackoverflow.com/questions/10947298/redirecting-websocket-traffic-on-port-80-with-lighttpd