# Unbreakable 90 sec timeout

**URL:** <https://www.ruby-forum.com/t/unbreakable-90-sec-timeout/202751>\
**Category:** NGINX\
**Created:** [February 4, 2011, 11:12pm UTC](https://www.ruby-forum.com/t/unbreakable-90-sec-timeout/202751 "2011-02-04T23:12:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 4, 2011, 11:12pm UTC](https://www.ruby-forum.com/t/unbreakable-90-sec-timeout/202751/1 "2011-02-04T23:12:18Z")

</div>

Hello.

I’m spent half day to googling, reading documentation and try…

I have simple file to test what just sleep 120 second:

```auto
<?
sleep(120);
echo 'Done';
file_put_contents('test.date', date('c'));
?>
```

But nginx (binary Debian package) always fired error 504: `
504 Gateway Time-out
nginx/0.6.32
`  
after 90 seconds timeout.

In try solve problem I set to big values many timeout directives:

```auto
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
        proxy_read_timeout 600;
        fastcgi_read_timeout 600;
        client_body_timeout 600;
        client_header_timeout 600;
        send_timeout 600;
        fastcgi_connect_timeout 600;
        fastcgi_send_timeout 600;
```

but unfortunately it does not helps.

Full config used:

[code]server {  
listen 11.22.33.44:80;  
server\_name [example.com](http://example.com) [www.example.com](http://www.example.com);

```
    proxy_connect_timeout 1600;
    proxy_send_timeout 1600;
    proxy_read_timeout 1600;

    fastcgi_read_timeout 1600;
    client_body_timeout 1600;
    client_header_timeout 1600;
    send_timeout 1600;

    fastcgi_connect_timeout 1600;
    fastcgi_send_timeout 1600;

access_log /var/www/site/logs/nginx_access.log;
error_log /var/www/site/logs/nginx_error.log;

location / {
    proxy_pass http://127.0.0.1:8080;
    include /etc/nginx/proxy.conf;
    proxy_temp_path /var/nginx/proxy_temp;
    root /var/www/site/www/;
}

location ~*

```

^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|html|htm|mp3)$  
{  
root /var/www/site/www/;  
access\_log off;  
expires 30d;  
}  
}  
[/code]

What is also may be interesting - if directly ask Apache which act there  
as frontend - script work. Even via nginx script also run to end - date  
in file updated each time despite 504 error produced for user.

What more can I tune?

With best wishes, Pavel Alexeev.

Posted at Nginx Forum:

> **[Unbreakable 90 sec timeout](https://forum.nginx.org/read.php?2,172262,172262#msg-172262)**
>
> Hello. I'm spent half day to googling, reading documentation and try... I have simple file to test what just sleep 120 second: \[code\] \<? sleep(120); echo 'Done'; file\_put\_contents('test.date', date('c')); ?\> \[/code\]

---

<div class="post-metadata">

**Author:** ![Hubbitus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@Hubbitus](https://www.ruby-forum.com/u/Hubbitus)\
**Post date:** [February 8, 2011, 3:22pm UTC](https://www.ruby-forum.com/t/unbreakable-90-sec-timeout/202751/2 "2011-02-08T15:22:37Z")

</div>

Hey what say your php.ini thay you use for the PHP?

Is there the problem?

Posted at Nginx Forum:

> **[Re: Unbreakable 90 sec timeout](https://forum.nginx.org/read.php?2,172262,173202#msg-173202)**
>
> Hello. I'm spent half day to googling, reading documentation and try... I have simple file to test what just sleep 120 second: \[code\] \<? sleep(120); echo 'Done'; file\_put\_contents('test.date', date('c')); ?\> \[/code\]

---

<div class="post-metadata">

**Author:** ![Hubbitus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@Hubbitus](https://www.ruby-forum.com/u/Hubbitus)\
**Post date:** [February 8, 2011, 3:25pm UTC](https://www.ruby-forum.com/t/unbreakable-90-sec-timeout/202751/3 "2011-02-08T15:25:07Z")

</div>

I think i found your Problem: you need to insert the timeout variables  
into the location of your proxy request.

note: after the proxy include 😉

Posted at Nginx Forum:

> **[Re: Unbreakable 90 sec timeout](https://forum.nginx.org/read.php?2,172262,173204#msg-173204)**
>
> Hello. I'm spent half day to googling, reading documentation and try... I have simple file to test what just sleep 120 second: \[code\] \<? sleep(120); echo 'Done'; file\_put\_contents('test.date', date('c')); ?\> \[/code\]

---

<div class="post-metadata">

**Author:** ![Hubbitus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@Hubbitus](https://www.ruby-forum.com/u/Hubbitus)\
**Post date:** [February 9, 2011, 10:59am UTC](https://www.ruby-forum.com/t/unbreakable-90-sec-timeout/202751/4 "2011-02-09T10:59:55Z")

</div>

Indeed!  
Thank you very much for the help. You are right - included  
/etc/nginx/proxy.conf defines such timeout.

But if I want redefine its values afte inclusion I got error like:

`[emerg]: "proxy_send_timeout" directive is duplicate in
/etc/nginx/sites-enabled/detishop:18
configuration file /etc/nginx/nginx.conf test failed`

Is there way have included common settings and just redefine some  
for concrete location or server?

Posted at Nginx Forum:

> **[Re: Unbreakable 90 sec timeout](https://forum.nginx.org/read.php?2,172262,173459#msg-173459)**
>
> Hello. I'm spent half day to googling, reading documentation and try... I have simple file to test what just sleep 120 second: \[code\] \<? sleep(120); echo 'Done'; file\_put\_contents('test.date', date('c')); ?\> \[/code\]

---

<div class="post-metadata">

**Author:** ![Hubbitus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@Hubbitus](https://www.ruby-forum.com/u/Hubbitus)\
**Post date:** [February 9, 2011, 2:34pm UTC](https://www.ruby-forum.com/t/unbreakable-90-sec-timeout/202751/5 "2011-02-09T14:34:50Z")

</div>

Hubbitus,

It should work if you include the file in the server location and  
override it in  
your location.

Something like :  
server {  
include /etc/nginx/proxy.conf;  
location / {  
proxy\_send\_timeout 1600;  
}  
}

You got the idea, I guess.

Antoine.

----- Original Message ----
