Options -Indexes not working

March 2, 2019 298 views
Apache Ubuntu

I am trying to configure a new droplet to disable Indexes on Apache2. However, no matter how I do it, I am able to view the index:

<Directory /var/www/>
Options FollowSymLinks
Options -Indexes
AllowOverride None
Require all granted
</Directory>

/etc/init.d/apache2 restart

Then when I load my droplet IP - http://xx.xx.xx.xx, I see the directory contents.

Any ideas what I’m doing wrong please? Thank you

3 Answers
appl3s March 4, 2019
Accepted Answer

Ok, I’ve finally figured this out. Chalk it up to newbiness.

To anyone else having this issue - after some digging around, I noticed that /etc/apache2/sites-enabled had its own conf, which I believe is what @jarland was noting above as being a vhost conf? My understanding was that vhost was not enabled by default. But it seems it is?

Anyway, putting my conf directives in /etc/apache2/sites-enabled/000-default.conf, followed by a restart, worked as expected.

Thank you

Hey friend,

Make sure there are not any other configurations that may be overriding this. For example, if you’re placing that in the virtual host config then it might be overridden by /etc/apache2/apache2.conf. This is in my default install right now, for example:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Jarland

Thank you for the reply, @jarland . At the moment I am not using vhost. The conf is made directly in /etc/apache2/apache2.conf:

<Directory /var/www/>
Options -FollowSymLinks -Indexes
AllowOverride None
Require all granted

    <LimitExcept GET POST>
            Deny from all
    </LimitExcept>

</Directory>

There is no ’<Directory /var/www/html>’ and the actual /var/www/html directory is empty, meaning no .htaccess.

Any ideas please? Thank you

  • Hmm, interesting. For kicks, what about this?

    grep -R "Indexes" /etc/apache2
    

    I could be wrong I just feel like something is overriding it, and maybe that will help identify some more references to it. Can’t hurt to find other references and adjust them, even if they seem like they shouldn’t cause an override.

    • I wish I was aware of this previously because it did in fact identify the other .conf that was being loaded. As noted below in my other comment - this is all (obviously) due to my inexperience and misunderstanding. Thank you so much for your time and help, @jarland.

Have another answer? Share your knowledge.