8

我有一个托管在 lighttpd 上的网站,可通过“www”子域访问。我也有一个聊天服务器在用 node.js 和 socket.io 监听端口 8124。

我希望所有客户端流量都发生在端口 80 上,方法是将所有请求重定向到“聊天”子域到端口 8124。所以我启用了 mod_proxy 并在 lighttpd.conf 中添加了:

$HTTP["host"] == "chat.myserver.com" {
    proxy.server = (
            "" => ((
                    "host" => "78.128.79.192",
                    "port" => "8124"
            ))
    )
}

在客户端,当我连接到 websocket 时,

var socket = io.connect('http://chat.myserver.com');

我从 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::

但是浏览器报错:

Firefox can't connect to server ws://chat.myserver.com/socket.io/1/websocket/6067470561567883577

当然,如果我直接连接到端口 8124,一切正常:

var socket = io.connect('http://www.myserver.com:8124');

但是,正如我所说,我希望所有客户端流量都在端口 80 上。这可能吗?

4

1 回答 1

8

已知 mod_proxy 与 websockets 不兼容。

HAProxy是兼容的(我自己没有测试过,但是这里有一篇关于它的 websockets 配置的文章)。

于 2012-06-08T11:03:19.937 回答