【发布时间】:2011-08-12 06:47:13
【问题描述】:
现在,我用nginx_tcp_proxy_module 修补了nginx,它在8080 端口上运行正常。
如何将客户端连接到 nignx 的 80 端口,而不是 Node.js 的 8080 端口, 让 nginx 将请求转发给 Node.js?
【问题讨论】:
标签: node.js nginx websocket socket.io
现在,我用nginx_tcp_proxy_module 修补了nginx,它在8080 端口上运行正常。
如何将客户端连接到 nignx 的 80 端口,而不是 Node.js 的 8080 端口, 让 nginx 将请求转发给 Node.js?
【问题讨论】:
标签: node.js nginx websocket socket.io
只需将8080改为80即可。但是TCP和HTTP在同一个端口is not possible。
Host: your.nodejs.socketio.com到127.0.0.1:8080 如果您沿着这条路线走,您可能希望保留客户端 IP:
在 socket.io 中使用 X-Forwarded-For
socketio.handshakeData = function(data) {
var d = socketio.Manager.prototype.handshakeData(data);
d.ip = data.request.headers['x-forwarded-for'] || data.request.connection.remoteAddress;
return d;
};
【讨论】:
acl is_websocket hdr(Upgrade) -i WebSocket