mod_spamhaus is an Apache module that use DNSBL in order to block spam relay via web forms, preventing URL injection, block http DDoS attacks from bots and generally protecting your web service denying access to a known bad IP address.

1. Installation (Debian GNU/Linux)

This module can be found in the main repositories of Debian (squeeze or later) and Ubuntu (jaunty jackalope or later):

apt-get install libapache2-mod-spamhaus

In order to compile mod_spamhaus, you will need to have apxs2 (APache eXtension tool) installed and configured with Apache.

The follow command will install it:

apt-get install apache2-prefork-dev

Now we download the source package present at or download it using wget application and this direct link to the repository:


Next open archive, compile and install module with those commands:

tar zxvf mod_spamhaus05.tar.gz
cd mod-spamhaus
make install

Add in the main config file of your web server the following command in order to load mod_spamhaus module.

vi /etc/apache2/httpd.conf

LoadModule spamhaus_module /usr/lib/apache2/modules/

2. Configuration
Before we are able to write our configuration, we should known what directives are supported by this module.

MS_Methods - If the httpd’s method used by the visitor match, module verify user’s ip address
MS_WhiteList - A simple whitelist file where you can put ip address to bypass
MS_DNS - DNSBL to use. Usefull if you want make a local rbldnsd instance
MS_CacheSize - Number of cached addresses

Now we open config file of our web server in order to write the configuration:

vi /etc/apache2/apache2.conf

<IfModule mod_spamhaus.c>
MS_WhiteList /etc/spamhaus.wl
MS_CacheSize 256

Finally we restart Apache:

/etc/init.d/apache2 restart