[英]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.