another "nested locations" question

Maxim Dounin mdounin at mdounin.ru
Thu Sep 27 13:41:09 UTC 2012


Hello!

On Thu, Sep 27, 2012 at 09:05:47AM -0400, AJ Weber wrote:

> So this probably will work if I have the access_log AND include a
> copy of the proxy_pass directives in the nested location.  The
> proxy_set_header, proxy_cache..., etc. would all be inherited
> automatically in the nested location, so I can leave those in the
> parent?

Yes.  You actually can leave those on server or even http level, 
and these directives will be inherited from there as well.

> 
> 
> On 9/26/2012 11:44 AM, Maxim Dounin wrote:
> >Hello!
> >
> >On Tue, Sep 25, 2012 at 10:05:44PM -0400, AJ Weber wrote:
> >
> >>I am interested in using a nesting of some sort so that I don't have
> >>to duplicate all the proxy- and other directives for one "special
> >>case".
> >>
> >>Basically, I'd like a very small subset of my webapp to also write
> >>to a separate access-log.  When a user hits that particular page, I
> >>would like to log it, AND also perform all the directives for the
> >>rest of the site that are already configured.
> >>
> >>Something like
> >>
> >>location /site {
> >>     location /site/search {
> >>         access_log /var/log/nginx/search_access.log;
> >>     }
> >>     proxy_pass ...
> >>     proxy_redirect off;
> >>     proxy_set_header ...
> >>}
> >>
> >>So accessing /site/search should write an entry in the "special log
> >>file", and then do all the "normal stuff" that location /site has
> >>itemized.
> >>
> >>Is this possible?
> >Not exactly.  Each location is expected to have it's own "do
> >something" list, i.e. if you need proxy_pass in this location -
> >you have to write it explicitly.
> >
> >On the other hand, there is no need to duplicate normal
> >configuration, e.g. proxy_redirect and proxy_set_header will be
> >inherited from previous level(s).  I.e. you have to write
> >explicitly only few directives which aren't inherited, notably
> >try_files, rewrite module directives, and content handlers like
> >proxy_pass.
> >
> >In the above config snippet you have to duplicate proxy_pass into
> >location /site/search.
> >
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

-- 
Maxim Dounin
http://nginx.com/support.html



More information about the nginx mailing list