我试图通过AWS Console在AWS Elastic Beanstalk中部署示例Nodejs应用程序。我的Nodejs应用程序仅包含HelloWorld消息。 我的问题是,当我点击Elastic Beanstalk网址时,我没有收到Hello world消息。我还检查了日志,但Nodejs.logs和Error.logs中没有错误消息。 当我检查Elastic Beanstalk URL是否因为内部服务器错误而导致连接被拒绝" 。我使用JSON模板通过控制台创建堆栈,我的模板包含应用程序,应用程序版本,环境和ConfigurationTemplate资源类型。我的ConfigurationTemplate资源类型 包含以下OptionSettings,如下所示 -
"OptionSettings": [
{
"Namespace": "aws:autoscaling:asg",
"OptionName": "MinSize",
"Value": "1"
},
{
"Namespace": "aws:autoscaling:asg",
"OptionName": "MaxSize",
"Value": "2"
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "EC2KeyName",
"Value": { "Fn::FindInMap": [ "Environments",{"Ref": "EnvironUsed"},"InstanceKeyName" ] }
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "IamInstanceProfile",
"Value": {"Fn::FindInMap": ["Environments",{"Ref": "EnvironUsed"},"IamRoleProfile"]}
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "InstanceType",
"Value": "t2.micro"
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "SecurityGroups",
"Value": { "Fn::FindInMap": [ "Environments",{"Ref": "EnvironUsed"},"BeanstalkSecurityGroup" ] }
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "VPCId",
"Value": { "Fn::FindInMap": ["Environments", {"Ref": "EnvironUsed"},"VPC" ]}
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "Subnets",
"Value": { "Fn::FindInMap": [ "Environments",{"Ref": "EnvironUsed"},"PrivateSubnet"]}
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "ELBSubnets",
"Value": { "Fn::FindInMap": [ "Environments", {"Ref": "EnvironUsed"}, "PrivateSubnet" ]}
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "ELBScheme",
"Value": "internal"
},
{
"Namespace": "aws:elasticbeanstalk:environment",
"OptionName": "EnvironmentType",
"Value": "LoadBalanced"
},
{
"Namespace": "aws:autoscaling:trigger",
"OptionName": "MeasureName",
"Value": "CPUUtilization"
},
{
"Namespace": "aws:autoscaling:trigger",
"OptionName": "Unit",
"Value": "Percent"
},
{
"Namespace": "aws:autoscaling:trigger",
"OptionName": "UpperThreshold",
"Value": "50"
},
{
"Namespace": "aws:autoscaling:trigger",
"OptionName": "LowerThreshold",
"Value": "49"
}
],
以下是我的样本节点应用 -
var express = require('express');
var http=require('http');
var app = express();
app.set('port', process.env.PORT || 8081);
app.get('/',function(req,res){
res.send('Hello World');
});
http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});
由于我对此AWS服务更新,请指导我如何解决此错误,因为我按照AWS文档中提供的所有说明创建此Elastic Beanstalk以部署应用程序。
答案 0 :(得分:0)
我会检查安全组允许的端口8081(或其他)上的连接