Allowing Access Only to Specific IP Addresses


<Directory /usr/local/apache2/htdocs/private>     Order Allow, Deny    Allow from 192.168.0 </Directory>


Sometimes, it is desirable to restrict access to certain content (such as a company's internal website) to specific IP addresses, such as those coming from an internal network. This example will allow access to the directory /usr/local/apache2/htdocs/private and its subdirectories only to clients with IP addresses in the range 192.168.0.1 to 192.168.0.254.

The argument passed to the Directory container must literally match the filesystem path that Apache uses to access the files.

The line Order Allow, Deny denies access by default and only clients that match the Allow directive will be granted access. The Allow directive can accept multiple individual IP addresses or a certain address range of IP addresses. Check the directive reference for details.

You can also allow access only to specific IP addresses using the same code in a .htaccess file in /usr/local/apache2/htdocs/private:

Order Allow,Deny Allow from 192.168.0





Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net