Subodh
Subodh

Reputation: 2214

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

Upvotes: 4

Views: 3108

Answers (2)

s01ipsist
s01ipsist

Reputation: 3137

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.

Upvotes: 4

Sachin Gevariya
Sachin Gevariya

Reputation: 1167

Try extreme timeouts to see if issue will reproduce

  • client_header_timeout 600s;
  • client_body_timeout 600s;
  • keepalive_timeout 600s;
  • proxy_read_timeout 600s;
  • proxy_send_timeout 600s;
  • lingering_timeout 600s;
  • lingering_time 600s;
  • send_timeout 600s;

Then restart nginx.

Upvotes: 0

Related Questions