# Location.nested location.which one is better?

**URL:** <https://www.ruby-forum.com/t/location-nested-location-which-one-is-better/244563>\
**Category:** NGINX\
**Created:** [May 4, 2016, 6:18am UTC](https://www.ruby-forum.com/t/location-nested-location-which-one-is-better/244563 "2016-05-04T06:18:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [May 4, 2016, 6:18am UTC](https://www.ruby-forum.com/t/location-nested-location-which-one-is-better/244563/1 "2016-05-04T06:18:22Z")

</div>

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:

> **[location...nested location...which one is better?](https://forum.nginx.org/read.php?2,266588,266588#msg-266588)**
>
> 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
