Similar to Apache’s Deny from all
, nginx has the deny all
directive.
To deny access to a directory called ‘dirdeny’ and return a “403 Forbidden” header, use this code within your configuration file:
location /dirdeny {
deny all;
return 403;
}