I want to restrict access to a given site based on two criteria:
- The IP address of the client (i.e. is it within an allowed range) and;
- Digest authentication.
However, for each range of IPs there will be a different list of username/password combinations (I'm segregating clients by source IP, then requiring authentication on top of that). Every client which comes from a valid IP and provides a matching username/password combination (or digest in this case) for that IP will connect to the same hostname and see the same site served from the same document root.
I'd like to keep this configuration in the Apache configuration if possible, to avoid reinventing the wheel in my application, and have something like this:
if client_ip = 1.1.1.1
digest_file = /etc/digests/customer1
elseif client_ip = 2.2.2.2
digest_file = /etc/digests/customer2
else
deny access
Is it possible to do this within a single virtual host? I'm running Apache 2.2.9 on Debian and have the ability to load modules if required.
I have also thought about using a different hostname and virtual host container for each customer, and putting a different IP range and digest file reference in each, but unfortunately this site will run over HTTPS and I suspect obtaining all the extra IPs would be prohibitive in terms of cost.