Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1.01 KB

File metadata and controls

42 lines (33 loc) · 1.01 KB

How can we prevent Directory Listing vulnerability in a web server

To prevent Directory Listing vulnerability in a web server we should edit the configuration files of the web server.

Depending of the web server we can do this:

.htaccess file

Create a .htaccess file in the related directory (on web site) and put this line:

Options -Indexes

For apache web server,

Add this line in httpd.conf files,

<Directory /var/www/public_html>
      Options -Indexes
</Directory>

For Nginx Server,

Edit the configuration file nginx.conf, it can be found at /usr/local/nginx/conf, /etc/nginx or /usr/local/etc/nginx

Modified, it would be something like:

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

The value off autoindex must be off