对 ELB [with proxy protocol] 和 Nginx 代理服务器后面的 Websockets 的请求

Requests to Websockets behind ELB [with proxy protocol] and Ngnix proxy server

我正在尝试获取连接到 Nodejs websocket 服务器的客户端 IP。 这个博客是我要做的 .这是 工作 并且正在获取客户端 IP。

现在我的问题是: 一旦通过 ELB 和 ngnix 从客户端到服务器建立了初始握手和连接;来自客户端的后续请求[sendText()]是否会通过ELB 或者他们会绕过 ELB 直接进入 websoket 服务器。

示例客户端代码:

var connection = ws.connect('ws://<ELB>:80');
    connection.on("connect", function () {
                console.log("Connection established");
                connection.sendText("Hi");
                connection.sendText("Hello");           
        })

在评论中 here 我读到

2) From this moment on and for the lifetime of this TCP connection, the ELB maintains a quasi-direct connection between client and backend server. 3) "quasi-direct" means that the connection is proxied through the ELB. So while the TCP connection is alive, the ELB is fully aware of the two end points taking part (client and backend server). – Jan-Philip Gehrcke

我不清楚 tcp 请求 [不是握手和连接建立] 是直接到服务器还是通过 ELB->ngnix -> websoket 服务器。

在 ELB 中启用代理协议将在 headers 中添加源 ips、目标 ips 等信息,除此之外它不会做任何其他事情。所有对服务器的请求都将仅通过 elb。 如果你想验证它在私有子网中启动服务器,私有 ip 和 elb 在它上面,它仍然可以工作。