gpt4 book ai didi

node.js - nginx 和 socket.io 解决方法

转载 作者:搜寻专家 更新时间:2023-10-31 23:27:54 24 4
gpt4 key购买 nike

目前,在处理网络套接字时,很难绕过大多数反向代理(nginx、HAproxy)。我在想也许可以做这样的事情:

io.connect("http://yourdomain:8080/chat"); // with namespace

所以一个示例工作流是:

  • nginx 监听 80 端口
  • nodejs 监听8080端口
  • socket.io 通过nodejs应用监听8080端口
  • nginx 将端口 80 上的所有请求代理到 8080 上的 nodejs
  • socket.io 客户端直接连接到端口 8080 上的 Node/套接字服务器并直接通信,无需反向代理

我无法让它工作 - 这是不可能的,还是我做错了什么?

EDIT: This DOES actually work, my problem was sending MongoDB _id fields to the client.

我写了更详细的描述here

最佳答案

一旦 NGINX 1.3 发布,我应该可以使用它。 1.2 版增加了对 HTTP/1.1 协议(protocol)的支持,这是必不可少的缺失部分。

关于node.js - nginx 和 socket.io 解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9900154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com