Allow from 18.104.22.168/8
Deny from all
AuthName "Authentication Required"
For more options, read the Apache documentation: http://httpd.apache.org/docs/2.2/mod/mod_auth_basic.html
But, the question is:
what if Apache stands behind a cache server (e.g. Varnish)?
If there is a proxy or cache server placed between users and the apache, all the requests come to apache will be recognized as proxy/cache server requests (proxy/cache server IP). It means that the above setting will not function as desired.
So, thing we have to do here is to make Apache recognize the real IP addresses of clients from http requests instead of proxy/cache server IP. And with the real IP addresses, Apache authentication filter IP range base can function correctly.
I will make a simulation demo and update this blog post later when I have chance.
For now, you can read the following links: