mod_cidr readme

=Headers=

mod_cidr will introduce the following headers to your HTTP variables:

  CIDR_CC
  CIDR_MASK
  CIDR_RANGE
  CIDR_RIR

CIDR_CC is a two letter country code, GB, FR, US etc.

CIDR_MASK is a 32-bit unsigned int of the network bit mask for the CIDR match.

CIDR_RANGE is a 32bit unsigned int of the range (length) of the IP netmask. This is not really essential but in some cases it could be of use.

CIDR_RIR is a optional field that states where the allocation is located.

=Creating your own .cdb file=

The easiest way to do this is using a PERL script and CDB_File since it's a relatively simple interface to use.

The important information is that the hash key should be a unsigned int for the network address and the key value should be four null terminated values.

	$cdb->insert( $CIDR_NETMASK, "$CIDR_RANGE\0$CIDR_MASK\0$CIDR_RIR\0$CIDR_CC" );

For example.

A better example is the script that makes the .cdb file called process_data.pl.

process_ip.pl is an example of reading the data from the .cdb.

=Uses=

This module can be used as a geo-location database, it provides the web server with some information about the inbound IP. You might want to treat requests from a certain IP range differently, perhaps to bounce the inbound request to a geographically closer proxy with a temporary redirect.

This author advises that you do not use this information for page language. A much better method is to use the inbound request to determine this as the browser can set a preferred language which might differ from the country where the request originates.

=Installation=

Define the location of your .cdb file using

CIDR_CDB_File /localtion/to/file.cdb

In your virtual host definitions.

Using the apxs auto-load might require the following header in your apache httpd.conf:

apxs:Error: Activation failed for custom /etc/apache2/httpd.conf file..
apxs:Error: At least one `LoadModule' directive already has to exist..


# This is here for backwards compatability reasons and to support
#  installing 3rd party modules directly via apxs2, rather than
#  through the /etc/apache2/mods-{available,enabled} mechanism.
#
#LoadModule mod_placeholder /usr/lib/apache2/modules/mod_placeholder.so

=Thanks=

The CDB interface itself, outside of mod_cidr.c was written by DJB, http://cr.yp.to.

As I understand it this is now in the public domain.

$Id: README 94 2008-02-11 20:28:39Z ed $
