How to control NGINX 'Location' directive matching order?
From the wiki:
location = / { # matches the query / only. [ configuration A ] }location / { # matches any query, since all queries begin with /, but regular # expressions and any longer conventional blocks will be # matched first. [ configuration B ] }
So, this will be matched first:location ~ \.php$ {}
Even though assets are served out of location / {}
Inside the php block you also want to secure against malicious uploads before passing to fastcgi:
if ($uri ~* "^/uploads/") { return 404;}
As you can see nginx works a little bit differently than you might expect.