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:
Â Options Indexes FollowSymlinks MultiViews
Â AllowOverride None
Â order deny,allow
Â deny from all
Â # Allow LAN Location A
Â allow from 172.16.2.0/24
Â # Allow LAN Location B
Â allow from 172.16.3.0/24
Â # Allow VPN-subnet
Â allow from 172.16.250.0/24
Â # 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.