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

Solution: I have to put the allow/deny directives inside the first Directory directive(which also happens to be for the root). I'm guessing it's because it has a AllowOverride None that does't allow any children to specify allow/deny?

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
        Deny from xxx.xx.xxx.xx
</Directory>

Original:

This configuration still allows access to all IPs after apache restart

<VirtualHost *:80>

    ServerName  www.xxx.com

    DocumentRoot  /var/www/vhosts/xxx

    <Directory /var/www/vhosts/xxx>
        Options Indexes FollowSymLinks
        AllowOverride none
        Order deny,allow
        Deny from all                     
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>
share|improve this question
    
So you did have two <Directory> directive's like I surmised? Putting that directive on the root is an unusual step. –  Patrick R Feb 18 '10 at 2:48

4 Answers 4

For what you want to do, that is, only allow 127.0.0.1, you should do the following :

Order Allow,Deny
Allow from 127.0.0.1

Which says first, allow things, then deny things, and deny things that did not match.

You should also not put your <Directory> block inside your <VirtualHost> one, but before it.

share|improve this answer
    
Mat's definition should work. I'm still curious as to why yours doesn't. –  Patrick R Feb 17 '10 at 23:47
    
@Mat - I think I'm misunderstanding you. Are you suggesting that one put the <Directory> block outside of the <VirtualHost> block? I must be misunderstanding you. How will the <Directory> be applied to the appropriate virtualhost? –  Patrick R Feb 18 '10 at 0:19

That should work. I just verified your code on my server to make sure I wasn't crazy. Are you sure you don't have a definition before this one that is taking precedence?

Create a test file in the folder on your server. Something like test.txt. You may find that you don't see it when you load that url in your browser. If that's the case then your definition above is getting skipped.

share|improve this answer
1  
There's an AllowOverride none so, a .htaccess should not be able to do anything. –  mat Feb 18 '10 at 0:06
    
Right again Mat. I'll remove that from what I said. –  Patrick R Feb 18 '10 at 0:14
    
I have a sneaky suspicion that your <Directory> conditions will still be skipped altogether even if you used Mat's good answer. –  Patrick R Feb 18 '10 at 0:23

Is this a Plesk system? Sometimes you have to watch how the various http includes are being compiled. You may have something in a later include file that is over writing your first statement.

share|improve this answer

Thanks. this code works.

NameVirtualHost 127.0.0.1

NameVirtualHost 192.168.44.141

<VirtualHost 127.0.0.1 192.168.44.141>

#ServerName localhost.com
    ServerName www.localhost.com
DocumentRoot  "E:/abcd"
<Directory "E:/abcd/files">
    Options Indexes FollowSymLinks
        AllowOverride none
    Order allow,deny
    Allow from 192.168.44.128
    Deny from all

  </Directory>
 </VirtualHost>
share|improve this answer
    
it works either use "Allow from" or "Deny from" in VirtualHost block. If i try to use both lines in VirtualHost block, it will not properly work. –  sivaguru Feb 25 '13 at 11:22

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.