我試圖通過AWS Console在AWS Elastic Beanstalk中部署示例Nodejs應用程序。我的Nodejs應用程序僅包含HelloWorld消息。 我的問題是我沒有收到你好世界消息,當我點擊Elastic豆莖網址。我也檢查了日誌,但Nodejs.logs和Error.logs中沒有錯誤消息。 當我檢查Elastic Beanstalk URL獲取「連接被拒絕 - 由於內部服務器錯誤」。我通過控制檯創建堆棧使用JSON模板和我的模板中包含應用程序,應用程序版本,環境和ConfigurationTemplate國土資源類型。我ConfigurationTemplate國土資源型 ,則爲以下OptionSettings如圖所示如下─如何將node.js應用程序部署到AWS Elastic Beanstalk
"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"
}
],
以下是我的樣本一個應用的NodeJS -
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文檔給創建這個彈性魔豆的所有指令解決這個錯誤部署應用程序。
請回答這個問題。 –
我也有這個問題,任何解決方案? – Marko