Apache – Access based on an IP or Username/password | Just my blog


Apache – Access based on an IP or Username/password

Recently I came along the need of having access to some intranet site based on IP or if the IP was outside the LAN apache should prompt for a username/password.

It took me some time to figure out, but this can be done by the satisfy
option. So I now have in my apache-config the next configuration:

<Directory "/usr/local/www/intranet">
  Options Indexes FollowSymlinks MultiViews
  AllowOverride None
  order deny,allow
  deny from all
  # Allow LAN Location A
  allow from
  # Allow LAN Location B
  allow from
  # Allow VPN-subnet
  allow from

  # Username/password request
  AuthType Basic
  AuthName "Example.Com Intranet"
  AuthUserFile /usr/local/etc/intranet/webusers.pwl
  require valid-user

  # Allow or require must be satisfied
  Satisfy any

And it is working well, if you're from outside the defined subnets... you need to enter your username/password.

  • Social

  • By continuing to use the site, you agree to the use of cookies. more information

    The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible and enable advertising to provide you free content. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.