【问题标题】:Replace default nginx config elastic beanstalk NodeJS Amazon Linux替换默认 nginx 配置 elastic beanstalk NodeJS Amazon Linux
【发布时间】:2021-11-26 08:41:34
【问题描述】:

我的 NodeJS 应用程序在 Elastic Beanstalk 上运行,平台:Node.js 在 64 位 Amazon Linux 上运行

有一个问题 worker_connections 不够。

1024 worker_connections are not enough while connecting to upstream

这是在 elastic beanstalk nginx.conf 文件中设置的默认 worker_connections

nginx.conf

# Elastic Beanstalk Nginx Configuration File
user  nginx;
worker_processes  auto;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
  worker_connections  1024; # <-- want to change this number
}
http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;
  access_log    /var/log/nginx/access.log;
  
  log_format  healthd '$msec"$uri"$status"$request_time"$upstream_response_time"$http_x_forwarded_for';
  include       /etc/nginx/conf.d/*.conf;
  include       /etc/nginx/sites-enabled/*;
}

我想增加worker_connections的数量。

为此,我需要替换默认的nginx.conf,但我找不到这样做的方法。

在 AWS 文档中,http 部分中只有一个覆盖 nginx 配置的指南。

请帮忙!谢谢

【问题讨论】:

标签: node.js amazon-web-services nginx amazon-elastic-beanstalk


【解决方案1】:

AWS docs 解释了如何为 AL1 执行此操作。就像 AL2 一样,您必须使用 .ebextensions/proxy.config覆盖整个 nginx 文件 (/etc/nginx/conf.d/proxy.conf)。

你可以试试.ebextensions/proxy.config:

files:
  /etc/nginx/conf.d/proxy.conf:
    mode: "000644"
    owner: root
    group: root
    content: |
        user  nginx;
        worker_processes  auto;
        error_log  /var/log/nginx/error.log;
        pid        /var/run/nginx.pid;
        events {
          worker_connections  1024; # <-- want to change this number
        }
        http {
          include       /etc/nginx/mime.types;
          default_type  application/octet-stream;
          access_log    /var/log/nginx/access.log;
          
          log_format  healthd '$msec"$uri"$status"$request_time"$upstream_response_time"$http_x_forwarded_for';
          include       /etc/nginx/conf.d/*.conf;
          include       /etc/nginx/sites-enabled/*;
        }


  /opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh:
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/bin/bash -xe
      rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
      service nginx stop 
      service nginx start

container_commands:
  removeconfig:
    command: "rm -f /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf"

【讨论】:

  • 有效吗?在文档中。我只看到它可以覆盖http部分里面的内容?
  • @TanDat 你可以试试看。
  • @TanDat 进展如何?仍然不清楚你能做什么?
  • 它不起作用:(
猜你喜欢
  • 2015-02-23
  • 2019-01-01
  • 2018-02-27
  • 2020-08-27
  • 2020-08-27
  • 2013-06-23
  • 2014-11-22
  • 2019-09-24
  • 2014-04-24
相关资源
最近更新 更多