简体   繁体   中英

aws beanstalk nodejs: how to override 60s timeout of nginx

I want to increase the default timeout of nginx in a nodejs environment in AWS elastic beanstalk, i'm following this guide: https://medium.com/swlh/using-ebextensions-to-extend-nginx-default-configuration-in-aws-elastic-beanstalk-189b844ab6ad but it's not working, if i upload my application i receive this error Unsuccessful command execution on instance id(s) 'i-xxxxxxxxxx'. Aborting the operation. any suggestion? i'm trying to use.ebextension and this is the code of my 01-timeout.config file

files:
"/etc/nginx/conf.d/01-timeout.conf":
 mode: “000644”
 owner: root
 group: root
 content: |
   keepalive_timeout 600s;
   proxy_connect_timeout 600s;
   proxy_send_timeout 600s; 
   proxy_read_timeout 600s; 
   fastcgi_send_timeout 600s; 
   fastcgi_read_timeout 600s;
container_commands:
  nginx_reload:
   command: "sudo service nginx reload"

Thanks for any help.

Update now the deploy it's ok, but the timeout doesn't work, it's like before with the timeout of 60s, reading the logs seems that the reload of nginx it's made, this is the message: Command nginx_reload succeeded, any clue of what is the problem?

.ebextension method is not working now.Please try .platform method.

Please create a folder called .platform in your project root folder.

.platform/
         nginx/
              conf.d/
                    timeout.conf
         00_myconf.config

Content of File 1 - timeout.conf (Inside .platform/nginx/conf.d/ folder)

keepalive_timeout 600s;
proxy_connect_timeout 600s;
proxy_send_timeout 600s; 
proxy_read_timeout 600s; 
fastcgi_send_timeout 600s; 
fastcgi_read_timeout 600s;

Content of File 2 - 00_myconf.config (Inside .platform/ folder)

container_commands:
  01_reload_nginx:
    command: "service nginx reload"

reupload your application and see the changes.

Your /etc/nginx/conf.d/01-timeout.conf is ignored because this is a valid file for EB platforms based on Amazon Linux 1 (AL2). However, it seems to me that you are using new, current versions of EB based Amazon Linux 2 (EB).

For AL2, the nginx settings should be in .platform/nginx/conf.d/ , not in .ebextentions as shown in the docs in the "Reverse proxy configuration" section.

Therefore, you could have the following .platform/nginx/conf.d/myconfig.conf with content:

keepalive_timeout 600s;
proxy_connect_timeout 600s;
proxy_send_timeout 600s; 
proxy_read_timeout 600s; 
fastcgi_send_timeout 600s; 
fastcgi_read_timeout 600s;

Manual restart of nginx using sudo service nginx reload couldn't be needed.

Please try it like this:

files:
  "/etc/nginx/conf.d/01-timeout.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      keepalive_timeout 600s;
      proxy_connect_timeout 600s;
      proxy_send_timeout 600s; 
      proxy_read_timeout 600s; 
      fastcgi_send_timeout 600s; 
      fastcgi_read_timeout 600s;

container_commands:
  nginx_reload:
    command: "sudo service nginx reload"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM