通过Elastic Beanstalk访问我的节点服务器时遇到问题 .

Process of what I did:

  • 通过openssl创建自签名证书

  • 设置弹性beanstalk环境 . 使用端口8443设置入站安全组,并将出站设置为所有流量 .

  • 上传到Load Balancer

  • 使用端口8443创建新侦听器 . 附加SSL证书 . 禁用其他端口 .

  • 上传服务器代码 . 附上部分代码 .

var https = require('https');
var express = require('express');
var app = express();

// other packages ...

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.get(‘/path’, function (req, res) {

 // ignore ..

});

https.createServer(function (req, app) {

  // ignore ..

}).listen(8443);

Also tried to set in this way:

app.set('port', process.env.PORT || 8443);
 app.listen(app.get('port'));

当我尝试访问时,这两种方式对我来说似乎都不起作用

https://xxxx-env.xxxx.us-west-2.elasticbeanstalk.com

根据我在这里找到的参考资料(How to download Certificate and Private Key on AWS EC2 when using NodeJS),我认为在创建https服务器时我不需要设置证书 .

这是否意味着我必须购买证书而不是使用自签名?

谢谢!