0

我正在尝试在 Elastic Beanstalk 上创建一个节点 js 应用程序。在 Amazon Linux Image 上,环境被创建并且运行顺利。为了完成它,我遵循了 AWS 文档本身中给出的说明。它适用于单个实例。此外,使用 Nginx 并按照此处的信息终止了实例上的 HTTPS 应用程序的根目录包含:

  • .ebextensions
  • index.js
  • 包.json

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

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

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 上部署应用程序,应用程序的根文件夹包含以下文件/文件夹:

  • .ebextensions/https-instance.config 和 .ebextensions/https-instance-single.config
  • .platform/nginx/conf.d/extendnginx.conf (为了扩展 nginx 配置以终止实例的 https)
  • index.js
  • 包.json

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

4

2 回答 2

1

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

于 2020-09-14T12:46:45.553 回答
0

是的,现在它正在工作!所以遵循@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;
} 
于 2020-09-15T04:59:21.187 回答