0

My NodeJS Application is running on Elastic Beanstalk, platform: Node.js running on 64bit Amazon Linux.

There is an issue worker_connections is not enough.

1024 worker_connections are not enough while connecting to upstream

This is the default worker_connections set in elastic beanstalk nginx.conf file

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.

To do that it means I need to replace default nginx.conf, but I can't find a way to do this.

In AWS doc, there is only a guide to override nginx config inside http section.

Please help! Thanks

Tan Dat
  • 2,888
  • 1
  • 17
  • 39
  • Does this answer your question? [Increasing worker\_connections of nginx on Beanstalk nodejs environment](https://stackoverflow.com/questions/66343544/increasing-worker-connections-of-nginx-on-beanstalk-nodejs-environment) – Ervin Szilagyi Oct 06 '21 at 06:57
  • No I'm using Amazon Linux 1, not Amazon Linux 2 – Tan Dat Oct 06 '21 at 06:58

1 Answers1

0

The AWS docs explain how to do it for AL1. Just like for AL2, you have to overwrite entire nginx file (/etc/nginx/conf.d/proxy.conf) using .ebextensions/proxy.config.

You can try with .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"
Marcin
  • 215,873
  • 14
  • 235
  • 294