简体   繁体   English

替换默认 nginx 配置 elastic beantalk NodeJS Amazon Linux

[英]Replace default nginx config elastic beanstalk NodeJS Amazon Linux

My NodeJS Application is running on Elastic Beanstalk, platform: Node.js running on 64bit Amazon Linux .我的 NodeJS 应用程序在 Elastic Beanstalk 上运行,平台: Node.js 在 64 位亚马逊 Linux 上运行

There is an issue worker_connections is not enough.有一个问题 worker_connections 是不够的。

1024 worker_connections are not enough while connecting to upstream

This is the default worker_connections set in elastic beanstalk nginx.conf file这是弹性 beantalk nginx.conf 文件中设置的默认 worker_connections

nginx.conf 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/*;
}

I want to increase worker_connections number.我想增加worker_connections数量。

To do that it means I need to replace default nginx.conf , but I can't find a way to do this.为此,这意味着我需要替换默认nginx.conf ,但我找不到执行此操作的方法。

In AWS doc, there is only a guide to override nginx config inside http section.在 AWS 文档中,只有一个指南可以覆盖http部分中的 nginx 配置。

Please help!请帮忙! Thanks谢谢

The AWS docs explain how to do it for AL1. AWS 文档解释了如何为 AL1 执行此操作。 Just like for AL2, you have to overwrite entire nginx file ( /etc/nginx/conf.d/proxy.conf ) using .ebextensions/proxy.config .就像 AL2 一样,您必须使用.ebextensions/proxy.config覆盖整个 nginx 文件( /etc/nginx/conf.d/proxy.conf )。

You can try with .ebextensions/proxy.config :您可以尝试使用.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"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elastic Beanstalk - 升级后将 .htaccess 替换为 nginx - Elastic Beanstalk - replace .htaccess for nginx after upgrade 访问在 AWS Linux 上运行的 NGINX 配置中的 Elastic Beanstalk 环境属性 2 - Access Elastic Beanstalk environment properties in NGINX configs running on AWS Linux 2 Amazon Elastic Beanstalk - 更改时区 - Amazon Elastic Beanstalk - Change Timezone AWS Elastic Beanstalk Docker 未将默认的 nginx 反向代理设置为应用程序端口 - AWS Elastic Beanstalk Docker is not setting a default nginx reverse proxy to application port NodeJS Elastic Beanstalk 环境报错 Cannot find module 'node-linux-arm64/package.json' - NodeJS Elastic Beanstalk environment error Cannot find module 'node-linux-arm64/package.json' Amazon Elastic Beanstalk 不提供 django static 个文件 - Amazon Elastic Beanstalk not serving django static files 在 Elastic Beanstalk 上更改 nginx.conf? - Change nginx.conf on Elastic Beanstalk? 使用Elastic Beanstalk时,Docker在64bit Amazon Linux 2平台上运行和ECS在64bit Amazon Linux 2平台上运行有什么区别? - What's the difference between Docker running on 64bit Amazon Linux 2 and ECS running on 64bit Amazon Linux 2 platforms when using Elastic Beanstalk? AWS Elastic Beanstalk - Ruby 3.0 在 64 位亚马逊上运行 Linux 2/3.4.4 - 100.0% 的请求失败并显示 HTTP 5xx - AWS Elastic Beanstalk - Ruby 3.0 running on 64bit Amazon Linux 2/3.4.4 - 100.0 % of the requests are failing with HTTP 5xx Elastic Beanstalk - 从标头中删除 Nginx 版本 - Elastic Beanstalk - Remove Nginx version from headers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM