5

please, help me configure nginx so that it will hide files and directories from directory listing. Setting "Autoindex off" is not an option because nginx starts showing 403 error message. What I need is sort of a blank page with a directory name. Thank you.

6

Add an empty page named "index.html" into each directory, you'd like to hide and that's it. This works on Nginx, Apache and what ever.

| improve this answer | |
  • Or index.php, or index.any_extension, depending on what's set for index directive. This is the method used by WordPress on some important directories! Just adding what's already mentioned by @Jens. – Pothi Kalimuthu Oct 7 '13 at 4:25
-1

Directory listing is disabled by default on the nginx. To control indexing, one can use autoindex parameter together with location:

server {
        listen   80;
        server_name  domain.com www.domain.com;
        root   /path/to/root;
        location / {
                index  index.php index.html index.htm;
        }
        location /somedir {
               autoindex on;
        }
}

In the example above directory listing is enabled only in the /somedir.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.