2
votes

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?

3
check your elastic beanstalk logs, you may find the reason why the command failed, or maybe there is just a space missing before nginx_reload but not sure about that.Olivier Krull
you were right, i found this error:2020/08/31 13:19:40 [emerg] 18127#0: unknown directive "files:" in /var/proxy/staging/nginx/conf.d/01-timeout.conf:7 but how can i solve that?user273686
it may be the indentation, try indenting the files: content by two spaces and also indenting everything under /etc/nginx.... except container_commandsOlivier Krull

3 Answers

1
votes

.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.

1
votes

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"
1
votes

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.