x-accel-redirect and status codes
Maxim Dounin
mdounin at mdounin.ru
Wed Apr 8 01:51:43 MSD 2009
Hello!
On Tue, Apr 07, 2009 at 02:32:46PM -0700, Brian Moran wrote:
> We'd like nginx to be able to return a 404 error page using
> x-accel-redirect, BUT also have the status code returned to be 404; is
> this possible?
I don't actually understand reason - if you want 404 content to be
returned by frontend, you may use proxy_intercept_errors.
But if you really want to, try something like this:
location = /redirect-404-here {
error_page 404 /404.html;
return 404;
}
location = /404.html {
# here actual content should be returned
# it will have 404 status
...
}
and return "X-Accel-Redirect: /redirect-404-here". If you want
the same for multiple different files - it's easy too, just use
variables in error_page uri.
Maxim Dounin
More information about the nginx
mailing list