'Unable to increase the timeout on AWS Elastic Beanstalk
I'm trying to increase the timeout on Amazon Elastic Beanstalk but I still get a 504 Gateway timeout.
Here's what I've done so far:
.ebextensions/timeouts.config:
option_settings:
  - namespace: aws:elb:policies
    option_name: ConnectionSettingIdleTimeout
    value: 940
  - namespace: aws:elbv2:loadbalancer
    option_name: IdleTimeout
    value: 940
files:
  "/etc/nginx/conf.d/nginx.timeouts.conf":
      mode: "644"
      owner: "root"
      group: "root"
      content: |
        client_header_timeout   5;
        client_body_timeout     10;
        send_timeout            940;
        proxy_connect_timeout   2;
        proxy_read_timeout      940;
        proxy_send_timeout      10;
container_commands:
  01_update_nginx:
    command: "sudo sed -i 's/keepalive_timeout  65;/keepalive_timeout  940;/g' /etc/nginx/nginx.conf"
  02_restart_nginx:
    command: "sudo service nginx restart"
Procfile:
web: gunicorn --bind :8000 --workers 10 --timeout 935 --graceful-timeout 935 main:app
Despite this, I still get a "504 Gateway Time-out" after exactly 60.1 seconds.
What am I missing that should make it work?
Solution 1:[1]
Your /etc/nginx/conf.d/nginx.timeouts.conf does not work because this is a valid file for EB platforms based on Amazon Linux 1 (AL1). However, it as confirmed in the comments, you are using  AL2.
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 try creating the following .platform/nginx/conf.d/myconfig.conf file with the content of:
client_header_timeout   5;
client_body_timeout     10;
send_timeout            940;
proxy_connect_timeout   2;
proxy_read_timeout      940;
proxy_send_timeout      10;
Solution 2:[2]
Just to post something slightly more updated; https://stackoverflow.com/a/63772786's answer worked for me.
The big "aha!" was creating a .platform/nginx/conf.d/nginx.custom.conf file with the contents. Laid out.
You can run nginx -T to ensure the file contents were adopted by nginx.
I also kept an .ebextension file with:
option_settings:
  - namespace: aws:elbv2:loadbalancer
    option_name: IdleTimeout
    value: 180
container_commands:
  01_restart_nginx:
    command: "sudo service nginx reload"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | Marcin | 
| Solution 2 | Jeremy Smith | 

 amazon-web-services
amazon-web-services amazon-elastic-beanstalk
amazon-elastic-beanstalk