wrong status code when proxying 404 errors

Igor Sysoev is at rambler-co.ru
Fri Feb 8 10:02:07 MSK 2008


On Thu, Feb 07, 2008 at 09:23:10PM +0100, Jodok Batlogg wrote:

> i'm trying to use an upstream proxy to generate a 404 error page.
> my config looks like that:
> 
> 
>  location '/error/404' {
>      rewrite ^/(.*) /news/404  break;
>      proxy_pass http://backend_varnish;
>  }
> 
>      error_page 404 = /error/404;
> 
> 
> unfortunately nginx returns a response header of 200 OK
> 
> i also tried
> 
> error_page 404 =404 /error/404;
> 
> but that doesn't work as well.
> any ideas?

First, some optimization:

  location = /error/404 {
      proxy_pass http://backend_varnish/news/404;
  }

Second, you should use either

      error_page 404 /error/404;

or

      error_page 404 =404 /error/404;

But not

      error_page 404 = /error/404;

unless http://backend_varnish/news/404 returns 404 status.

If the first two variants do not work, could you should debug log ?


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list