Christy Herron
Christy Herron

Reputation: 714

Apache directory listing

I am unable to stop apache from creating directory listings when using the server IP address. I have tried editing the relevant site-available files as follows;

<VirtualHost *:80>
    JkMount /* default
    ServerName example.co.uk
    ServerAlias www.example.co.uk
    ServerAdmin [email protected]
    DocumentRoot /var/www/example.co.uk/public_html
    ErrorLog /var/www/example.co.uk/logs/error.log
    CustomLog /var/www/example.co.uk/logs/access.log combined
    <Directory /var/www/example.co.uk/public_html>
        Options -Indexes
    </Directory>
</VirtualHost>

...but the public_html folder contents are being listed if I access the server using a url of this format;

http://192.168.1.99/example.co.uk/public_html

I have also tried to amend the apache config file at /etc/apache2/apache.conf to include the following;

<Directory />
    Options -Indexes
</Directory>

..but no joy.

I am using Tomcat, and I need my WEB-INF folder to deny access. It doesn't, and so any .class files can be downloaded.

Does anyone know how I can fix this?

thanks

Upvotes: 0

Views: 1468

Answers (3)

wemu
wemu

Reputation: 8160

This sounds a little weird. Do you have an Apache HTTPD in front of an Apache Tomcat Server?

In this case the Apache HTTPD must not point to a directory where the Apache Tomcat files reside! The communication between both can be seen more as a proxy rather than a plugin.

We have some good experience using mod_proxy_ajp for this purpose. But if you are able to download .class files and (panic mode on) the web.xml (panic mode off) something is terribly wrong.

Upvotes: 1

rkosegi
rkosegi

Reputation: 14678

This means that it will not reach your VirtualHost settings, but default virtual host settings.

You have 2 options (at least):

1, put .htaccess file to your directory for which you want to restrict listing

2, Setup you IP based virtual host with similar settings as your name-based vhosts

You said that you put

<Directory />
    Options -Indexes
</Directory>

You should have Location instead of Directory there

Upvotes: 0

Attila Fulop
Attila Fulop

Reputation: 7011

What if you add /* to the end?

<Directory /var/www/example.co.uk/public_html/*>
        Options -Indexes
</Directory>

Update: Or try to add the entry outside the VirtualHost directive.

Upvotes: 0

Related Questions