【问题标题】:AWS ELB -> nginx -> socket.io node.js sticky load balancingAWS ELB -> nginx -> socket.io node.js 粘性负载均衡
【发布时间】:2017-06-06 00:38:54
【问题描述】:

我对此配置有疑问。我的 AWS ELB 接受端口 80 上的 TCP 连接,并使用代理协议将它们转发到监听端口 8080 的 nginx 实例。这个 nginx 节点应该使用 ip_hash 模块将用户固定到特定节点。

这工作得很好,但是 4 个节点中只有 2 个被使用,而不是在所有节点之间进行负载平衡,这是我的 nginx 配置

upstream socket_nodes {
    ip_hash;
    server a.server.com:2000;
    server a.server.com:2001;
    server a.server.com:2002;
    server a.server.com:2003;
}

# Accept connections via the load balancer
server {
  listen 8080 proxy_protocol;
  set_real_ip_from 0.0.0.0/32;
  real_ip_header proxy_protocol;
  charset utf-8;
  location / {
      proxy_pass http://socket_nodes;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
  }
}

【问题讨论】:

  • 曾经得到这个工作?

标签: node.js amazon-web-services nginx socket.io load-balancing


【解决方案1】:

与“循环”负载平衡不同,ip_hash 意味着对于任何给定的 IP 地址,NGINX 将始终转发到同一个应用程序实例。

【讨论】:

    猜你喜欢
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 2013-04-28
    • 1970-01-01
    • 1970-01-01
    • 2016-08-16
    • 1970-01-01
    相关资源
    最近更新 更多