Saturday, May 27, 2017
Disable Directory Listing in Apache on Ubuntu 14 04 but should work in other versions as well
Disable Directory Listing in Apache on Ubuntu 14 04 but should work in other versions as well
If you are a newbie to setting up a web server on Ubuntu by yourself, you might have encountered this as I do:
This is called Directory Listing in Apache server settings. And this is turned on by default.
To check if you have this problem, try to visit a directory in your apache server location with a browser, such as : localhost/someFolder
If you see something similar to the above photo, you got this problem as well.
While it might not be a huge security problem to your site, it certainly makes you not comfortable, and it is also not a very pleasant experience for users to crash into your directory like this.
However, it is actually very easy to turn it off in Ubuntu, here is how.
1. Open Nautilus (Ubuntus default file explorer,) as root in terminal using this command:
sudo nautilus
2. Then, navigate to /etc/apache2
3. From there, you will find a file named :
apache2.conf
4. Open apache2.conf with your favorite text editor.
5. Find this line: ( there are actually two lines of these, ones under <Directory /var/www/>, and another one is under <Directory /srv/>, for now, we will work on the former one since thats where our website is in.)
Options Indexes FollowSymLinks
6. Remove Indexes from this line, so that it will look like this
Options FollowSymLinks
7. Save the file, open a terminal then restart apache.
sudo service apache2 restart
And we are done, try to visit a directory under your web var/www in a browser, and you will get a 403 forbidden error.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.