Skip to main content
Version: 8.2411.x.x RR

IPv4 geolocation

Identifying a client by its country code may be used for several purposes:

  • Statistics: get an understanding which country your web page is accessed from.
  • Country-specific web pages: redirect users to their country-specific home page.
  • Implement country-specific bandwidth limitations.
  • Detect the change of a user's country of origin during a session.

The nevisProxy package contains the "lite" edition of the IP2Location country database which may be loaded into the nevisProxy instance. A more accurate version of this database is the commercial edition which you may buy at http://www.ip2location.com. The qsgeo tool may be used to convert the IP2Location country database files into the format readable by nevisProxy.

Command example to create your own ip2location.csv file:

sed < IP2LOCATION-LITE-DB1.CSV -e 's:,"-","-":,"XX","UNKNOWN":g' > ip2location_in.csv
/opt/nevisproxy/bin/qsgeo -d ip2location_in.csv -l > ip2location.csv

As the database is a comma-separated list of address ranges and their country code (text file, not a binary file format), you might also use a database file from other sources, e.g., Maxmind.

The database file needs to be loaded into nevisProxy using the QS_ClientGeoCountryDB directive of the Apache module mod_qos, see also the chapter Optional Apache modules. The client's country code (two-character ISO 3166 codes are used, extended by the codes "PV" for private networks and "LO" for the local loopback interface) will then be available within the QS_Country environment variable.