[英]How to serve a nodeJS app via HTTPS on AWS EC2?
我正在尝试在 EC2 实例上运行一个 hello world express 应用程序并通过 HTTPS 为其提供服务。
这是服务器代码:
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!\n');
});
const server = app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
server.keepAliveTimeout = 65000; // Ensure all inactive connections are terminated by the ALB, by setting this a few seconds higher than the ALB idle timeout
server.headersTimeout = 66000; // Ensure the headersTimeout is set higher than the keepAliveTimeout due to this nodejs regression bug: https://github.com/nodejs/node/issues/27363
我创建了一个 EC2 实例并让它在那里运行。 此外,为了获得 HTTPS,我使用 SSL 证书启动了一个应用程序负载均衡器。 我在端口 443 上创建了一个侦听器,并将其转发到我的 EC2 上的端口 3000。 最后,我设置了一个 Route53 条目以指向该 ALB。
我得到的 24/7 是502 Bad Gateway
。 我在这里缺少一些基本的东西吗?
如何通过HTTPS运行最基本的快递服务器?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.