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 want to restrict the access to my Apache HTTPD using basic auth for all files except those in a certain directory.

The following works fine for setting up basic auth for the whole server:

<Directory />
    AuthType Basic
    AuthName "Private"
    AuthUserFile /usr/local/apache/passwd/passwords
</Directory>

However, I also want to restrict the directory /foo to a single host, regardless of the basic auth:

<Directory /foo>
    Order Deny,Allow
    Deny from all
    Allow from my-host.com
</Directory>

Both settings work fine on their own, but I cannot get them to work in combination:

  • By default (or if I use Satisfy all in the /foo clause) users need to come from the right host and have valid credentials to access /foo
  • If I use Satisfy any in the /foo clause then users can have either valid credentials or come from the right host

However, I want only people from my-host.com to have access to /foo without basic auth. Connections from other hosts should not be allowed even with correct credentials. In fact, those connections shouldn't even be prompted for basic auth credentials.

What am I missing?

share|improve this question
add comment

1 Answer

Can you try it with an empty passwd file for /foo

<Directory /foo>
  Order Deny,Allow
  Deny from all
  Allow from my-host.com
  AuthType Basic
  AuthName "my-host only"
  AuthUserFile /usr/local/apache/passwd/empty
  Satisfy any
</Directory>
share|improve this answer
    
Thanks for the tip. However, I chose basic auth just as an example. In the real application we're currently using LDAP authentication. Nevertheless I'd like to solve this problem in general, i.e. regardless of the authentication method that is used. –  Florian Brucker May 31 '12 at 6:07
add comment

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.