将 node.js 应用程序部署到 Amazon Linux 上的 Elastic Beanstalk 时出错 2

Error deploying a node.js app to Elastic Beanstalk on Amazon Linux 2

我正在尝试在 Elastic Beanstalk 上安装一个节点 js 应用程序。 在 Amazon Linux Image 上,环境已创建并运行 smooth.In 为了完成它,我按照 AWS 文档本身中给出的说明进行操作。它使用 Nginx 在单个 instance.Also 上运行,并通过遵循信息 here 终止了实例上的 HTTPS 应用程序的根目录包含:

按照 AWS 文档中给出的所有这些说明逐步创建环境并成功部署应用程序(对于 Amazon Linux 图片)。

但是,一直在尝试将其部署到 Amazon Linux 2.And 部署失败,环境的健康状态为“已降级”。

eb-engine.log的片段:

[INFO] 
> grpc@1.24.3 install /var/app/staging/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

Failed to execute '/opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/var/app/staging/node_modules/grpc/src/node/extension_binary/node-v64-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/var/app/staging/node_modules/grpc/src/node/extension_binary/node-v64-linux-x64-glibc --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)

web.stdout.log 的片段:

Sep 13 12:55:31 ip-172-31-1-73 web: > nodetryapp@1.0.0 start /var/app/current
Sep 13 12:55:31 ip-172-31-1-73 web: > node index.js
Sep 13 12:55:31 ip-172-31-1-73 web: [DEFAULT]
Sep 13 12:55:32 ip-172-31-1-73 web: events.js:174
Sep 13 12:55:32 ip-172-31-1-73 web: throw er; // Unhandled 'error' event
Sep 13 12:55:32 ip-172-31-1-73 web: ^
Sep 13 12:55:32 ip-172-31-1-73 web: Error: listen EACCES: permission denied 0.0.0.0:80
Sep 13 12:55:32 ip-172-31-1-73 web: at Server.setupListenHandle [as _listen2] (net.js:1260:19)

来自 nginx/error.log 的片段:

 2020/09/13 13:06:31 [alert] 4023#0: *1021 1024 worker_connections are not enough while connecting to upstream, client: 127.0.0.1, server: , request: "GET /hudson HTTP/1.1", upstream: "http://127.0.0.1:80/hudson", host: "*SOME IP ADDRESS*"

用于在 Amazon 上部署应用程序 Linux 2 Elastic beanstalk 应用程序的根文件夹包含以下内容 files/folders:

实例类型为单实例,t2.micro。

您不能在端口 80 和 443 上 运行 您的应用程序,因为这些端口专供 Beanstalk AMI 中的 Nginx/Apache 服务使用。不要使用这些端口,而是使用 8080 进行 HTTP 连接,使用 8443 进行 HTTPS 连接。

是的,现在它正在运行!所以按照@Raul Barreto 在上面的回答中所说的进行操作。 进行了以下更改: 'port' 环境变量现在设置为 8080。 在.platform/nginx/conf.d/extendnginx.conf文件中添加

upstream nodejs {
    server 127.0.0.1:8080;
} 

而不是

upstream nodejs {
    server 127.0.0.1:80;
}