Nested location block for merging config returns 404?

Jonathan Matthews contact at jpluscplusm.com
Tue Jan 21 13:48:22 UTC 2014


On 21 January 2014 13:40, WheresWardy <nginx-forum at nginx.us> wrote:
> I don't think it's a regex issue, because if I add an additional proxy_pass
> inside the nested location block, I then get a valid request. Additionally,
> any headers set inside the outer location block don't appear, but then if I
> duplicate them inside the nested location block, they then appear (just the
> once).

You may have multiple things to solve here.

Your line

  location \.(txt|css) {

looks like a regex, but you're not telling nginx it /is/ a regex. I
wouldn't expect anything to work until you fix that.

Secondly, the inheritance behaviours you're seeing are as I'd expect:

1) I don't believe proxy_pass statements are inherited, both as you're
seeing from outer-location{} to inner-location{} but also from, for
example, server{} to location{}. You need to define each proxy_pass
where you want it to be used.

2) add_header (again, in my understanding) is a slightly different
beast: it *is* inherited, outer to inner, but only if you *don't*
re-use it in the inner location. As soon as you use it inside the
inner location, all the inherited add_header directives are forgotten.
Again - that's what I /think/ is the case - I welcome others to
correct me if I'm misremembering ...

Cheers,
Jonathan



More information about the nginx mailing list