Proxy pass location inheritance

Francis Daly francis at
Mon Feb 17 09:16:55 UTC 2014

On Mon, Feb 17, 2014 at 08:55:02AM +0000, Brian Hill wrote:

Hi there,

> Regex 1 & 3 look for the same file types and are identical, but contain different configurations based on the parent location. Currently, regex1 is catching all matches, irrespective of the parent location.
> If I understand correctly, I could solve my problem by moving the regex2 location block before the / location block, and then rewriting regex3 so that it included the elements of both the current regex2 and regex3. That way, regex3 would ONLY hit for items that matched both the current regex2 and regex3, and it would appear before regex1 in the order of execution.
> Is this correct, or will NGINX always give priority to the / location?

Replace the directives inside the regex1 and regex3 locations with things

  return 200 "Inside regex1\n";

and you should be able to test it straightforwardly enough.

Alternatively, the mail you are replying to includes the words

Locations given by
regular expressions within a matching prefix location are tested
before other locations given by regular expressions.

If that's not clear, or if you want to test whether it matches what you
observe, a similar "return" configuration should work too.

(I'd say that your suggestion won't work as you want it to, because "/" is
still the best-match prefix location, and therefore regex matches within
"/" will be tested before regex matches outside of that location. You'll
be happier if you limit yourself to prefix matches at server level.)

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list