HostOnNet Blog

Blocking Traffic With Apache GeoIP Module

Looking for Linux Server Admin or WordPress Expert? We can help.

To install GeoIP module in CentOS Apache server, run

yum install -y GeoIP mod_geoip

Now verify mod_geoip installed in apache by running

httpd -M | grep geoip


[root@3blogger ~]# httpd -M | grep geoip
 geoip_module (shared)
[root@3blogger ~]# 

Now edit /etc/httpd/conf/httpd.conf

vi /etc/httpd/conf/httpd.conf

add following

GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat

In your Apache VirtualHost, add

RewriteEngine On
RewriteRule ^(.*)$ [L]

This will block access from A1 (proxy IP) and RU. You can use any 2 letter code of any country to block traffic from the country.

Posted in Apache

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.