nested error_page

Igor Sysoev igor at sysoev.ru
Tue Dec 14 14:57:44 MSK 2010


On Tue, Dec 14, 2010 at 02:49:03PM +0300, Maxim Dounin wrote:

> 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.

Yes, you are right: it should be set in locations that allow several
error_page handling.


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



More information about the nginx mailing list