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.

I want to restrict a staging server with basic auth, except for one special location, which should not have basic auth but be restricted to a client IP block.

My virtual host section looks like this:

DocumentRoot /var/www/vhosts/example/public
ServerName beta.example.com

<Directory /var/www/vhosts/example/public>
    Options FollowSymLinks -MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

<Location />
    AuthUserFile /var/www/.htpasswd
    AuthType Basic
    AuthName "Secret"
    Require valid-user
</Location>

<Location /payment/ipn>
    # How can I disable basic auth here?

    Order deny,allow
    Deny from all
    Allow from 216.113.191
</Location>

So, nobody should be able to access the site, unless they know the password. But the PayPal Sandbox (216.113.191.xxx) should be able to access http://beta.example.com/payment/ipn to send instant payment notifications.

I'm hosting Rails 3 via Passenger on Apache2.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Sounds like you want Satisfy.

Satisfy Any
share|improve this answer

By default is set Satisfy All, then all authentication method should be true. Remember, subdirectory or sublocation inherits propertis from his master, and In your needs require should be any. If one requirement is done, other is not checked.

If you want more complicated behavior, you should use directives and . You can nest this directives creating complex cases. This all is described inside official apache docs, example is here: http://httpd.apache.org/docs/current/mod/mod_authz_core.html

share|improve this answer

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.