location...nested location...which one is better?

meteor8488 nginx-forum at forum.nginx.org
Wed May 4 04:18:10 UTC 2016


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: https://forum.nginx.org/read.php?2,266588,266588#msg-266588



More information about the nginx mailing list