nginx websocket upgstream模块开发

发布于 2024-10-02 18:46:13 字数 593 浏览 4 评论 0原文

我正在尝试让 nginx 反向代理 websocket 连接,以便我可以在同一端口上托管 Rails 应用程序。

考虑到我们忽略了 8 字节内容长度握手问题,我对这个主题有几个问题:

  1. 如果我要为当前的 http 上游实现 1.1 keep-alive,这是否允许我使用 nginx 作为反向代理后端的node.js websocket服务器实例?
  2. (我不确定我是否理解正确)考虑到我正在实现上游 keepalive,这是否意味着客户端和 nginx 之间的每个连接也会导致 nginx 和 node.js 后端之间的连接,只要客户端是否已连接到 websocket?如果是这种情况,是否与 nginx 的连接处理方式冲突?
  3. 如果 1. 成立,您能给我一些关于我将如何实现这一点的提示吗?

谢谢, 礼萨

P.S.有一个 ngx-upstream-keepalive 模块不支持 http。 http://mdounin.ru/hg/ngx_http_upstream_keepalive/

I'm trying to get nginx to reverse proxy websocket connections so that i can host a rails application on the same port.

Considering we neglect the 8 byte content-length handshake issue, I have a couple of questions on this topic:

  1. if i were to implement 1.1 keep-alive for current http upstream, would that allow me to use nginx as a reverse proxy for a node.js websocket server instance at the backend?
  2. (and i'm not sure if i understand this correctly) considering i'm implementing upstream keepalive, would that mean that every connection between client and nginx also results in a connection between nginx and the node.js backend for as long as the client is connected to the websocket? if that's the case is that in any way conflicting with nginx' way of connection handling?
  3. if 1. holds, can you give me any hints on how i would approach implementing this?

Thanks,
Reza

P.s. There is an ngx-upstream-keepalive module which doesn't support http. http://mdounin.ru/hg/ngx_http_upstream_keepalive/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文