# Nginx+varnish & delivered error\_page

**URL:** <https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330>\
**Category:** NGINX\
**Created:** [July 28, 2010, 12:14pm UTC](https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330 "2010-07-28T12:14:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![revirii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d2c977/32.png) [@revirii](https://www.ruby-forum.com/u/revirii)\
**Post date:** [July 28, 2010, 12:14pm UTC](https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330/1 "2010-07-28T12:14:12Z")

</div>

Hello,

we have a little problem with, as the topic says, “Nginx+varnish &  
delivered error\_page”. We have nginx in front as proxy, behind there’s a  
varnish cashing stuff from a tomcat backend.

Sometimes the tomcat crashes and delivers 503 to varnish; varnish sends  
503 to nginx, nginx sends it to the client (browser, fiddler, …). I’ve  
created some 50x error page which is delivered via nginx:

```auto
        error_page 500 501 502 503 504 505 /500.htm;

        # location for error pages
        location = /500.htm {
            root /var/www/errorpages;
            internal;
        }
```

It worked as long as varnish wasn’t there, but now with varnish i can’t  
see my own error page anymore. Instead the default varnish 503 page (i  
think it’s some html code; but with correct 503 status code) is  
delivered. Does anyone know why this happens and has an idea how to  
prevent the varnish page to be delivered in favor of the nginx page?

thx  
revirii

Posted at Nginx Forum:

> **[Nginx+varnish & delivered error\_page](https://forum.nginx.org/read.php?2,113789,113789#msg-113789)**
>
> Hello, we have a little problem with, as the topic says, "Nginx+varnish & delivered error\_page". We have nginx in front as proxy, behind there's a varnish cashing stuff from a tomcat backend. Sometimes the tomcat crashes and delivers...

---

<div class="post-metadata">

**Author:** ![revirii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d2c977/32.png) [@revirii](https://www.ruby-forum.com/u/revirii)\
**Post date:** [July 28, 2010, 1:15pm UTC](https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330/2 "2010-07-28T13:15:06Z")

</div>

Today Jul 28, 2010 at 06:13 revirii wrote:

> It worked as long as varnish wasn’t there, but now with varnish i can’t  
> see my own error page anymore. Instead the default varnish 503 page (i  
> think it’s some html code; but with correct 503 status code) is  
> delivered. Does anyone know why this happens and has an idea how to  
> prevent the varnish page to be delivered in favor of the nginx page?

[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpProxyModule#proxy_intercept_errors)

“If you set this to on then nginx will intercept status codes that are  
explicitly handled by an error\_page directive. Responses with status  
codes  
that do not match an error\_page directive will be sent as-is from the  
proxied server.”

–  
WNGS-RIPE

---

<div class="post-metadata">

**Author:** ![revirii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d2c977/32.png) [@revirii](https://www.ruby-forum.com/u/revirii)\
**Post date:** [July 28, 2010, 1:50pm UTC](https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330/3 "2010-07-28T13:50:48Z")

</div>

that’s it - thx a lot 🙂

Posted at Nginx Forum:

> **[Re: Nginx+varnish & delivered error\_page](https://forum.nginx.org/read.php?2,113789,113807#msg-113807)**
>
> Hello, we have a little problem with, as the topic says, "Nginx+varnish & delivered error\_page". We have nginx in front as proxy, behind there's a varnish cashing stuff from a tomcat backend. Sometimes the tomcat crashes and delivers...

---

<div class="post-metadata">

**Author:** ![revirii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d2c977/32.png) [@revirii](https://www.ruby-forum.com/u/revirii)\
**Post date:** [July 28, 2010, 2:11pm UTC](https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330/4 "2010-07-28T14:11:18Z")

</div>

Hey,  
thought I’d chip in since I also use Varnish over nginx for caching (at  
least some parts)

On 28 jul 2010, at 14.04, Igor S. wrote:

> > created some 50x error page which is delivered via nginx:
> > 
> > It worked as long as varnish wasn’t there, but now with varnish i can’t  
> > see my own error page anymore. Instead the default varnish 503 page (i  
> > think it’s some html code; but with correct 503 status code) is  
> > delivered. Does anyone know why this happens and has an idea how to  
> > prevent the varnish page to be delivered in favor of the nginx page?
> 
> BTW, why do you prefer to use varnish instead of nginx built-in cache ?

The main reason I use varnish is wildcard purging.

---

<div class="post-metadata">

**Author:** ![revirii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d2c977/32.png) [@revirii](https://www.ruby-forum.com/u/revirii)\
**Post date:** [July 28, 2010, 2:05pm UTC](https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330/5 "2010-07-28T14:05:27Z")

</div>

On Wed, Jul 28, 2010 at 06:13:32AM -0400, revirii wrote:

> [code]  
> see my own error page anymore. Instead the default varnish 503 page (i  
> think it’s some html code; but with correct 503 status code) is  
> delivered. Does anyone know why this happens and has an idea how to  
> prevent the varnish page to be delivered in favor of the nginx page?

BTW, why do you prefer to use varnish instead of nginx built-in cache ?

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![revirii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d2c977/32.png) [@revirii](https://www.ruby-forum.com/u/revirii)\
**Post date:** [July 28, 2010, 2:23pm UTC](https://www.ruby-forum.com/t/nginx-varnish-delivered-error-page/192330/6 "2010-07-28T14:23:36Z")

</div>

## Igor S. Wrote:

> BTW, why do you prefer to use varnish instead of  
> nginx built-in cache ?

Well… we needed to do caching fast, and a co-worker is quite good in  
varnish issues. It would’ve taken longer to test how this (incl. cookie  
& session handling) is done in nginx. But maybe, when there’s some  
time… 🙂

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,113789,113815#msg-113815](http://forum.nginx.org/read.php?2,113789,113815#msg-113815)
