【问题标题】:Load Balancing in APIAxleAPIAxle 中的负载平衡
【发布时间】:2015-06-16 06:04:06
【问题描述】:

我的 REST API 在 2 个不同的实例中(不同的亚马逊盒子)。我前面有 APIAXLE,它工作正常。我想要的是对来自 APIAXLE 的请求进行负载平衡。

如何为此配置 nginx。

现在我已经将nginx配置如下:

upstream apiaxle_cluster {
       server 127.0.0.1:3001;
    }


server {
       listen 8000;
       server_name xx.xx.xxx.x;(IP 1st instance)

       location /abcd {
          proxy_pass http://127.0.0.1:3001;---------------> APIAXLE-PROXY running port
          proxy_set_header Host "placesv2.api.localhost";
       }

        location /oauth {
          proxy_pass http://127.0.0.1:2500;-------------->My REST API running port
          proxy_set_header Host "placesv2.api.localhost";
       }

    }
}

如何修改以上配置做负载均衡。 APIAXLE 中是否提供负载平衡??

【问题讨论】:

    标签: node.js nginx apiaxle


    【解决方案1】:

    您的配置全部使用本地主机 - 假设您想用您的休息服务主机 ips 替换它?

    如果你将它传递给上游,proxy_pass 基本上会进行负载平衡。看起来你需要两个端口来提供两个服务,所以我认为你可能需要两个上游(比我有更多 nginx fu 的人可能也可以消除它)。我会尝试以下方法:

    upstream apiaxle_cluster_abcd {
           server host1:3001;
           server host2:3001;
        }
    
    upstream apiaxle_cluster_auth{
           server host1:2500;
           server host2:2500;
        }
    
    server {
           listen 8000;
           server_name xx.xx.xxx.x;(IP 1st instance)
    
           location /abcd {
              proxy_pass apiaxle_cluster_abcd
              proxy_set_header Host "placesv2.api.localhost";
           }
    
            location /oauth {
              proxy_pass apiaxle_cluster_auth
              proxy_set_header Host "placesv2.api.localhost";
           }
    
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-09-21
      • 2014-02-04
      • 2022-01-10
      • 1970-01-01
      • 2010-09-28
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多