Nginx Library

A repository of Nginx-related articles

Denying access to a directory

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;
If you find this article helpful, please consider making a donation.