Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phusion Passenger + Nginx : Set Connection Timeout parameter in nginx conf

What is the connection timeout option that should be included in Nginx if I want to increase the timeout for all the requests?

Currently, any request taking more than a minute gets timed out with 504 Connection Timed Out in browser, and I want to increase that time.

Here is my current config in Nginx:

server {
    listen       443;

    ssl                  on;
    ssl_certificate      /opt/nginx/certs/ssl.pem;
    ssl_certificate_key  /opt/nginx/certs/ssl.key;
    keepalive_timeout 75;
    ssl_session_timeout  5m;

    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    server_name  <server_url>;
    root         /home/ubuntu/rails_app/public;
    passenger_enabled on;
    error_page   500 502 503 504  /50x.html;
}

I have already tried including the following options but doesn't work -

proxy_connect_timeout
proxy_send_timeout
proxy_read_timeout
send_timeout
like image 524
Subodh Avatar asked Sep 15 '25 21:09

Subodh


1 Answers

One scenario that presents the same conditions is where nginx is behind a load balancer like AWS Application, or Elastic, Load Balancer (ALB).

The ALB has a configurable "Idle Timeout", which defaults to 60 seconds.

If no response is received within the Idle Timeout, ALB closes the connection. The nginx log will show an HTTP 499 error, "Client Closed Request". https://httpstatuses.com/499

ALB will return a 504 Connection Timed Out error to the user's browser. https://httpstatuses.com/504

The ALB "Idle Timeout" will provide a ceiling and must be raised before any downstream nginx or passenger timeout will have any affect.

like image 114
s01ipsist Avatar answered Sep 19 '25 15:09

s01ipsist