Two jumps using error_page directive

Kamil Gorlo kgorlo at
Tue Jan 12 16:19:27 MSK 2010

Hi all,

I have problem using error_page directive, here is main part of
problematic config:

    upstream test {
      server localhost:2009;

    upstream test2 {
      server localhost:2010;

    server {
      listen 80;

      location / {
        proxy_pass http://test;
        error_page 404 500 502 = @fail;

      location @fail {
        proxy_pass http://test2;
        error_page 404 500 502 /50x.html;

      location = /50x.html {
        root /var/www/nginx-default;

This is of course minimal config with the same problem I have in more
complicated scenario.

Here is my case: assume both test and test2 upstreams are dead. I want
to see nice static page with error explanation (/50x.html) but this is
not working. Instead, I see standard nginx 502 error. So only first
error_page directive caused jump to @fail location but then 502 didn't
cause second jump to /50x.html. Why?

I hope everything is clear enough :)



More information about the nginx mailing list