Location.nested location.which one is better?

Hi all,

I’m running a website which is based on php.
And I’m trying to use naxsi for my website. But it seems to enable
naxsi, we
need to put below line within a location:

include /etc/nginx/naxsi.rules;

And an interesting thing I found about location, is that people are
using
different location sections as following:

example 1

server {
root…
location / {
# …
location ~ .php$ {
#…
}
location ~*^.+.(jpg|jpeg|gif|png|bmp|ico|mp3)$ {
#…
}
}
}

example 2
server {
root…
location / {
# …
}
location ~ .php$ {
#…
}
location ~*^.+.(jpg|jpeg|gif|png|bmp|ico|mp3)$ {
#…
}
}

example 3
server {
root…

location ~ .php$ {
#…
}
location ~*^.+.(jpg|jpeg|gif|png|bmp|ico|mp3)$ {
#…
}
}

For my server, I’m using example 3.

So, is there any performance difference between these 3 different
configuration? And which one is better?

And for naxsi, it’s easy to include the configuration file in example 1.
But
for example 2 and 3, how to include the files?

Thanks

Posted at Nginx Forum: