Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm attempting to configure an Apache HTTP Server installation and I'm having a problem getting the Deny directive to work properly in both a general or VirtualHost context for some reason.

I stripped out as much as I could to try to isolate the problem, yet even this simple case doesn't work.

The httpd.conf file is simply:

ServerName localhost

<Directory />
    Order Allow,Deny
    Deny from All
</Directory>

The virtual host's configuration file looks like this:

<VirtualHost *:80>
    ServerName site-1.mydomain.com
    ServerAdmin webmaster@mydomain.com
    DocumentRoot /var/www/site-1.mydomain.com/docroot/

    <Directory />
        Order Allow,Deny
        Deny from all
    </Directory>

</VirtualHost>

Yet for some reason, the Deny directive doesn't work, and site-1.mydomain.com/index.html for example, loads normally when requested.

What could I be missing here? Any help would be much appreciated.

share|improve this question
    
Are you changing the right config file? Are you restarting the server after doing these changes? –  Khaled Dec 15 '10 at 8:03
    
Yes I'm sure I'm using the correct configuration file, because if I change the directive to Location, access is denied as expected. I just need to get it working for Directory as well. Thanks! –  Leirith Dec 15 '10 at 21:56

1 Answer 1

Try:

    <Location />
    Order Allow,Deny
    Deny from all
    </Location>
share|improve this answer
    
+1, With Directory / one would refer to the root of the filesystem, not the DocumentRoot. –  weeheavy Dec 15 '10 at 13:28
    
Using <Location /> works correctly, however I am concerned about using it to restrict directories deeper within the webspace, because of the warning presented in the apache documentation [httpd.apache.org/docs/2.0/sections.html], which instructs never to use location for this purpose. How can I make it work using <Directory /> ? I tried using <Directory /var/www/site-1.mydomain.com/docroot/> but that didn't work. Any advice would be appreciated. –  Leirith Dec 15 '10 at 21:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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