Disable Access to a folder in Nginx

To disable access to folder /admin in Nginx, add following to server block of your web site.

location /admin {
    deny all;
    return 404;
}

To disable access to some common virtual control software, use

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}
Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *