Nginx: Deny scripts from running in a directory as well as all its subdirectories

Solution 1:

First of all, nginx does not execute scripts. Under some conditions it could proxy request to other server that execute script. Most commonly condition is extension of file in request and typical nginx config block looks like this:

location ~* \.php$ {
  fastcgi_pass backend;
  ...
}

So your question should be: how to prevent proxying requests to folder /uploads/? And with this typical config answer is as simple as:

location ^~ /uploads/ {
}

which means: if request to folder uploads, just serve them as static files, do not try to look for regexp locations for them (that require you to understand different types of nginx locations).

If your config is much different from typical one, we need to see it to give you proper answer.