Wrong status code when proxying 404 errors

hi,

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?

thanks

jodok

remove the =

On 2/7/08, Jodok B. [email protected] wrote:

}
but that doesn’t work as well.
any ideas?

thanks

jodok


Abdul-Rahman A.

IM: [email protected]

Hello Jodok,

Friday, February 8, 2008, 2:23:10 AM, you wrote:

hi,

i’m trying to use an upstream proxy to generate a 404 error page.
my config looks like that:

  • location ‘/error/404’ {
  • 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?

thanks

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

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 ?