Apache: Require username/password authentication except from a single IP, host or network

Posted Over 13 years ago. Visible to the public.

You configured authentication in your Apache configuration that requires username and password but you want a single IP address, host or network to allow access without entering credentials you can use the code below.

To allow a network you can use CIDR notation like this:
Allow from 1.2.3.4/24
This would match 1.2.3.0-255. Simple matching does work as well:
Allow from 1.2.3

<Location />
  AuthType Basic
  AuthName "Secured"
  AuthUserFile /path/to/.htpasswd
  Require valid-user
  Satisfy any
  Deny from all
  Allow from 1.2.3.4
</Location>
Thomas Eisenbarth
Last edit
About 13 years ago
Keywords
apache, authentication, basic, auth, allow, deny
License
Source code in this card is licensed under the MIT License.
Posted by Thomas Eisenbarth to makandra dev (2010-12-19 14:21)