AWS负载平衡端口3000上的Node.js应用程序 [英] AWS Load Balancing a Node.js App on port 3000

查看:71
本文介绍了AWS负载平衡端口3000上的Node.js应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用默认端口3000的Node.js Express Web应用程序,通过弹性ip在Ubuntu EC2实例上响应良好.我正在尝试设置AWS内置的负载平衡,似乎无法通过良好的运行状况检查

I've got a Node.js Express web app that is using the default port 3000 and responds fine on an Ubuntu EC2 instance by elastic ip. I'm trying to setup Load Balancing built into AWS and can't seem to get a good health check to pass

设置2个ubuntu服务器,可以在端口3000上正常运行该应用程序.

Setup 2 ubuntu servers that server the app fine on port 3000.

设置端口80的负载平衡器侦听器路由到实例端口3000,并尝试将3000路由到3000.

Set the load balancer listeners for port 80 to route to Instance port 3000 and also tried routing 3000 to 3000.

为以防万一,将amazon-elb/amazon-elb-sg安全组添加到我的实例安全组中.

Added the amazon-elb/amazon-elb-sg security group to my instance security groups just in case.

将运行状况检查端口80和3000设置为项目中许多有效的URL.

Set the health check to port 80 and 3000 to many valid urls within the project.

我这里想念什么吗?

更新:

原来,这是我所忽略的最简单的事情.不知何故,我的实际实例位于一个只有80个打开的安全组中,而我只需要添加一个规则来打开3000个.简直不敢错过.

Turns out it was the simplest thing I was overlooking. Somehow my actual instances were in a security group with only 80 opened and I just had to add a rule to open 3000. Can't believe I missed that.

推荐答案

如果您设置的负载平衡器仅将端口80上的传入请求转发到后端实例上的端口3000,则当尝试使用80以外的端口.如果您针对端口3000发出请求(即 http://yourdomain.com:3000/uri ),您需要让负载均衡器还将实例3000上的传入请求转发到实例上的3000上.

If you have the load balancer set up only to forward incoming requests on port 80 to port 3000 on the backend instances, then you shouldn't get any response when trying ports other than 80. If you are making the requests against port 3000 (i.e. http://yourdomain.com:3000/uri) you need to have your load balancer also forward incoming requests on port 3000 to port 3000 on the instances.

如果在实例上仅使用端口3000,则需要确保运行状况检查指向端口3000.(例如,对/ping服务使用TCP ping 3000或HTTP到端口3000).

If you are using only port 3000 on the instances, then you need to make sure your health check points to port 3000. (i.e. TCP ping 3000, or HTTP to port 3000 against your /ping service).

这篇关于AWS负载平衡端口3000上的Node.js应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆