nested error_page

Maxim Dounin mdounin at mdounin.ru
Tue Dec 14 14:49:03 MSK 2010


Hello!

On Tue, Dec 14, 2010 at 10:12:38AM +0300, Igor Sysoev wrote:

> On Tue, Dec 14, 2010 at 03:07:08PM +0800, Mauro Stettler wrote:
> 
> > i have a situtation where i would need something similar to this:
> > 
> > location / {
> >   error_page 404 = /fallback_all;
> >   // do a request to get content from memcache, if not found go to /fallback_all

+     recursive_error_pages on;

> > }
> > 
> > location = /fallback_all {
> >   internal;
> >   error_page 404 = @404;
> >   // do a request to get content from fastcgi, if not found go to @404
> 
>     recursive_error_pages on;

-     recursive_error_pages on;

> > }
> > 
> > location @404 {
> >   internal;
> >   // real 404 page
> > }

Directive "recursive_error_pages on;" should be specified in the 
location which generates initial error (and in subsequent ones 
which have error_page set to "non-real" error pages), "location /" 
in this case.

Setting "recursive_error_pages on;" prevents nginx from setting 
the flag "we are in error handler" (r->error_page) when going to 
error_page.  This flag prevents further error_page processing.  If 
it's already set - recursive_error_pages does nothing.

Maxim Dounin



More information about the nginx mailing list