You might have uploaded dangerous file types to your server just to store them, but maybe you don’t want to serve them to the public. Dangerous file types include executable(.exe) and dynamic link libraries (.dll). To block all files with that file type, just use the following code snippet.

location ~ \.(exe|dll)$ {
     return 404;

That will match all files on the server_name with that end with .exe or .dll. You can add more blocked filed types by adding “|” and then your file type after “dll” between the parenthesis.