Apache IP based Access

GEEKS !!!

Here are some of the basics of restricting IP based access to directories in Apache i.e. /etc/httpd/conf/httpd.conf. I hope you still remember your RHCE Training.

Now these all 3 setting are the same.

10.0.0.0/255.0.0.0
10.0.0.0/8
10

But, this one is different

10.0.0.0/24 only allows 10.0.0.1 to 10.0.0.254

Here are some examples for your from /etc/httpd/conf/httpd.conf 

<Directory /var/www/html/networknuts>
Order allow,deny
Allow from 10.0.0.0/8 # All 10.
Allow from 192.168.0.0/16 # All 192.168
Allow from 127 # All 127.
</Directory>

Here’s an example that only allows access to .html files
and nothing else for a particular directory.

<Directory “/var/www/html/networknuts/secured”>
Satisfy All
Order allow,deny
Deny from all
<Files *.html>
Order deny,allow
Allow from all
Satisfy Any
</Files>
</Directory>

GEEKS don’t forget to reload httpd with the following command.

/etc/init.d/httpd reload

Enjoy your Sunday.

Advertisements