Nginx custom config

Hello,

i want to add the following code to one of my domains to prevent direct download of some files.

location ~ /folder {
     deny all;
     return 403;
}

i added it to home/user/conf/web/domain/nginx.conf

but it doesnt work for me. or is there any other way to block direct access to static files?

Hi @radexspox,

That location should work fine.

To prevent the conf from being overwritten, instead of nginx.conf, use nginx.conf_thenameyouwant to add this location block.

If your site uses SSL/TLS, you must also add it to an additional conf file nginx.ssl.conf_thenameyouwant

Remember to restart or reload nginx after creating the new conf files:

systemctl reload nginx
1 Like