# If proxy\_read\_timeout - then do something?

**URL:** <https://www.ruby-forum.com/t/if-proxy-read-timeout-then-do-something/218485>\
**Category:** NGINX\
**Created:** [April 2, 2012, 11:24am UTC](https://www.ruby-forum.com/t/if-proxy-read-timeout-then-do-something/218485 "2012-04-02T11:24:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 2, 2012, 11:24am UTC](https://www.ruby-forum.com/t/if-proxy-read-timeout-then-do-something/218485/1 "2012-04-02T11:24:08Z")

</div>

Hi,

I would like to put a proxy\_read\_timeout and if it times out, I want to  
do a specific action in php and return some response to the user. Is  
this possible? How?

Thanks,  
Shrinath

Posted at Nginx Forum:

> **[if proxy\_read\_timeout - then do something?](https://forum.nginx.org/read.php?2,224764,224764#msg-224764)**
>
> Hi, I would like to put a proxy\_read\_timeout and if it times out, I want to do a specific action in php and return some response to the user. Is this possible? How? Thanks, Shrinath

---

<div class="post-metadata">

**Author:** ![shrinath.m](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e274bd/32.png) [@shrinath.m](https://www.ruby-forum.com/u/shrinath.m)\
**Post date:** [April 2, 2012, 12:58pm UTC](https://www.ruby-forum.com/t/if-proxy-read-timeout-then-do-something/218485/2 "2012-04-02T12:58:30Z")

</div>

Hello!

On Mon, Apr 02, 2012 at 05:23:30AM -0400, shrinath.m wrote:

> Hi,
> 
> I would like to put a proxy\_read\_timeout and if it times out, I want to  
> do a specific action in php and return some response to the user. Is  
> this possible? How?

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page)**
>
> This directive appeared in version 1.11.8.

You have to handle 504 (Gateway Timeout) errors.

Maxim D.

---

<div class="post-metadata">

**Author:** ![shrinath.m](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e274bd/32.png) [@shrinath.m](https://www.ruby-forum.com/u/shrinath.m)\
**Post date:** [April 2, 2012, 3:29pm UTC](https://www.ruby-forum.com/t/if-proxy-read-timeout-then-do-something/218485/3 "2012-04-02T15:29:22Z")

</div>

I tried to catch 504, not working. Anything wrong in the following?

error\_page 504 =200 @checkstatus;

location @checkstatus  
{  
rewrite ^(.\*)$ /k/binarystatus/check?original\_uri=$1 break;  
proxy\_pass [https://shrinath.blah.com](https://shrinath.blah.com);  
proxy\_hide\_header Last-Modified;  
proxy\_read\_timeout 10s;  
proxy\_intercept\_errors on;  
}

Posted at Nginx Forum:

> **[Re: if proxy\_read\_timeout - then do something?](https://forum.nginx.org/read.php?2,224764,224776#msg-224776)**
>
> Hi, I would like to put a proxy\_read\_timeout and if it times out, I want to do a specific action in php and return some response to the user. Is this possible? How? Thanks, Shrinath

---

<div class="post-metadata">

**Author:** ![shrinath.m](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e274bd/32.png) [@shrinath.m](https://www.ruby-forum.com/u/shrinath.m)\
**Post date:** [April 2, 2012, 3:37pm UTC](https://www.ruby-forum.com/t/if-proxy-read-timeout-then-do-something/218485/4 "2012-04-02T15:37:25Z")

</div>

Oops… I take it back, it works…  
Ignorant me had one more line few lines above the said code:

error\_page 500 504 =500 @error50x;

Solved now… Thanks 🙂

Posted at Nginx Forum:

> **[Re: if proxy\_read\_timeout - then do something?](https://forum.nginx.org/read.php?2,224764,224777#msg-224777)**
>
> Hi, I would like to put a proxy\_read\_timeout and if it times out, I want to do a specific action in php and return some response to the user. Is this possible? How? Thanks, Shrinath
