This guide explains how to set up mod_geoip with lighttpd on a Debian Etch system. mod_geoip looks up the IP address of the client end user.
Read it at HowtoForge
This allows you to redirect or block users based on their country. You can also use this technology for your OpenX (formerly known as OpenAds or phpAdsNew) ad server to allow geo targeting. I will show two ways to build mod_geoip – the first way is to build a new lighttpd .deb package (including mod_geoip) which is the way I recommend. This works only if you have installed the standard Debian Etch lighttpd package. If you've compiled lighttpd yourself, then the second way is for you: it shows how to build mod_geoip.so for your lighttpd version.