If proxy_read_timeout - then do something?

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:

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?

http://nginx.org/r/error_page

You have to handle 504 (Gateway Timeout) errors.

Maxim D.

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;
proxy_hide_header Last-Modified;
proxy_read_timeout 10s;
proxy_intercept_errors on;
}

Posted at Nginx Forum:

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 :slight_smile:

Posted at Nginx Forum: