<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 6, 2014 at 8:39 PM, dcaillibaud <span dir="ltr"><<a href="mailto:nginx-forum@nginx.us" target="_blank">nginx-forum@nginx.us</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">> > 2) (I guess E but I'm not so sure), this can also be a pitfall<br>
> example (how<br>
> > complicating things can lead to unexpected behaviour)<br>
> ><br>
> > location /images/ {<br>
> > location ~* \.(gif|jpg|jpeg)$ {<br>
> > [ configuration D ]<br>
> > }<br>
> > }<br>
> ><br>
> > location ~* \.(gif|jpg|jpeg)$ {<br>
> > [ configuration E ]<br>
> > }<br>
<br>
<br>
</div>> The request processing stops on the first matching regex.<br>
<br>
Which is ?<br></blockquote><div><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Every request is processed through one location block at the same level.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
Said otherwise, every time there is a choice to be made between several location blocks, only one is picked up and entered. That process is recursive.<br></div><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">
In the provided example, there is only one regex at the root of the tree. Since the docs I quoted in my last message say that regexes have higher precedence, then E will be taken over D if both match. The regex inside the prefix location '/images/' has no impact/use in the current case since it is on the 2nd level of the tree, not its root, which was being considered. One step at a time :o)<br>
<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">Since regexes have higher precedence, and since it is prefered to use prefix locations (because they are more 'natural' and efficient, speaking about performance), it is then advised either:<br>
- to avoid mixing prefix and regex locations on the same level, thus encapsulating regex locations inside prefix ones first.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">
- to use the ^~ operator to force prefix locations being taken over the regex ones<br></div></div></div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font>
</div></div>