# Setting an error\_page for upstream timeouts

**URL:** <https://www.ruby-forum.com/t/setting-an-error-page-for-upstream-timeouts/215133>\
**Category:** NGINX\
**Created:** [December 23, 2011, 5:00am UTC](https://www.ruby-forum.com/t/setting-an-error-page-for-upstream-timeouts/215133 "2011-12-23T05:00:21Z")\
**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:** [December 23, 2011, 5:00am UTC](https://www.ruby-forum.com/t/setting-an-error-page-for-upstream-timeouts/215133/1 "2011-12-23T05:00:21Z")

</div>

I have a seemingly simple question about configuration, but have been  
unable to find the answer through searching so far. I just want to  
override  
the default 504 page when the upstream server times out, which I would  
have  
thought would be handled by the error\_page setting. Can anyone help?

My config looks like this (the variables are replaced before nginx is  
started):  
upstream jsweb {  
server 127.0.0.1:8091;  
}

server {  
listen $PORT$;  
server\_name localhost;  
root $CONTENT\_ROOT$;

```
location / {
  add_header X-Server-Name "$HOST_NAME$";
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_pass http://jsweb;
  error_page 502 503 504 $OUTAGE_PAGE$;
}

```

}

And the errors in the logs look like:

2011/12/23 03:50:35 [error] 13736#0: \*9 upstream timed out (110:  
Connection  
timed out) while reading response header from upstream, client:  
10.214.178.111, server: localhost, request: “GET /-/forgot\_password  
HTTP/1.1”, upstream: “[http://127.0.0.1:8091/](http://127.0.0.1:8091/)”, host: “[staging.myapp.com](http://staging.myapp.com)”

---

<div class="post-metadata">

**Author:** ![Dustin\_Moskovitz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@Dustin\_Moskovitz](https://www.ruby-forum.com/u/Dustin_Moskovitz)\
**Post date:** [December 23, 2011, 5:21am UTC](https://www.ruby-forum.com/t/setting-an-error-page-for-upstream-timeouts/215133/2 "2011-12-23T05:21:19Z")

</div>

On Fri, Dec 23, 2011 at 10:59 AM, Dustin Moskovitz  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a seemingly simple question about configuration, but have been unable  
> to find the answer through searching so far. I just want to override the  
> default 504 page when the upstream server times out, which I would have  
> thought would be handled by the error\_page setting. Can anyone help?

this parameter

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

should help.

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

---

<div class="post-metadata">

**Author:** ![Dustin\_Moskovitz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@Dustin\_Moskovitz](https://www.ruby-forum.com/u/Dustin_Moskovitz)\
**Post date:** [December 23, 2011, 1:17pm UTC](https://www.ruby-forum.com/t/setting-an-error-page-for-upstream-timeouts/215133/3 "2011-12-23T13:17:43Z")

</div>

Hello!

On Thu, Dec 22, 2011 at 07:59:20PM -0800, Dustin Moskovitz wrote:

> ```
> proxy_pass http://jsweb;
> error_page 502 503 504 $OUTAGE_PAGE$;
> }
> 
> ```
> 
> }
> 
> And the errors in the logs look like:
> 
> 2011/12/23 03:50:35 [error] 13736#0: \*9 upstream timed out (110: Connection  
> timed out) while reading response header from upstream, client:  
> 10.214.178.111, server: localhost, request: “GET /-/forgot\_password  
> HTTP/1.1”, upstream: “[http://127.0.0.1:8091/](http://127.0.0.1:8091/)”, host: “[staging.myapp.com](http://staging.myapp.com)”

And what’s wrong? Everything looks fine from here: nginx will log  
error and return error to client as specified in “$OUTAGE\_PAGE$”  
(I assume it’s something obfuscated or expanded by your  
configuration system).

Maxim D.

---

<div class="post-metadata">

**Author:** ![Dustin\_Moskovitz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@Dustin\_Moskovitz](https://www.ruby-forum.com/u/Dustin_Moskovitz)\
**Post date:** [December 23, 2011, 9:22pm UTC](https://www.ruby-forum.com/t/setting-an-error-page-for-upstream-timeouts/215133/4 "2011-12-23T21:22:12Z")

</div>

Thanks - that looks right on. I will give it a shot on Monday when I’m  
back  
at the office.

---

<div class="post-metadata">

**Author:** ![Dustin\_Moskovitz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@Dustin\_Moskovitz](https://www.ruby-forum.com/u/Dustin_Moskovitz)\
**Post date:** [December 24, 2011, 4:05am UTC](https://www.ruby-forum.com/t/setting-an-error-page-for-upstream-timeouts/215133/5 "2011-12-24T04:05:49Z")

</div>

On Sat, Dec 24, 2011 at 3:21 AM, Dustin Moskovitz  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks - that looks right on. I will give it a shot on Monday when I’m back  
> at the office.

sorry, my bad. You don’t need the proxy\_intercept\_errors, you just  
need to specify “location = $OUTAGE\_PAGE$ { }” block or make sure it’s  
not handled by “location / { }” block.

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)
