05 August 2010

Apache and bloquing IP address

Its always good and required to keep a close eye in the logs too see what's going on, who has accessed the website, what did they saw, etc. The metrics we can retrieve from the logs allow us to measure a lot of things and apply changes where required. It also allows us to identify potential IP address that are abusing the website.

Making usage of Apache mod_access we can block IP addresses from accessing the website.

To block a single IP address we can place this in our virtual host under Directory or Files sections or in .htacess file:
deny from 10.10.10.1

To deny access to everyone, you can use
deny from all

To deny access to a range of IP address:
deny from 10.10.10.1 10.10.10.255
Remember that every time a user connects to the Internet the ISP (internet service providers) we give him a IP on the range of IPS assigned to them.