How to start using GeoLite2(GeoIP) Database

About Geo2Lite

Since 4.5.8 version HAProxy-WI has ability to download and update GeoLite2 via web panel.

GeoIP, MaxMind’s IP intelligence product, consists of several related products. GeoIP lets you discover information about a specific IP address. Maxmind provides web services, subscription-based downloadable databases, and free downloadable databases.

Databases

GeoLite2 databases are free IP geolocation databases comparable to, but less accurate than, MaxMind’s GeoIP2 databases. The GeoLite2 Country, City, and ASN databases are updated weekly, every Tuesday.

IP Geolocation Usage

IP geolocation is inherently imprecise. Locations are often near the center of the population. Any location provided by a GeoIP database should not be used to identify a particular address or household.
Use the Accuracy Radius as an indication of geolocation accuracy for the latitude and longitude coordinates Maxmind returns for an IP address. The actual location of the IP address is likely within the area defined by this radius and the latitude and longitude coordinates.

Go to UP

Getting Licence Key

MaxMind provides access to GeoLite2 databases only after registration now. So, you need get Licence key before using. This instruction shows how to do it.

First of all create account here:

MaxMind sign up

After this step you will receive an email with next instructions:

MaxMind sign up

Follow the link for password creating:

MaxMind sign up

After finishing registration you can access into your private cabinet:

MaxMind sign up

For directly Database downloading you must get Licence key. Go to "My Licence Key" section: Follow the link for password creating:

MaxMind sign up

Next:

MaxMind sign up

Next:

MaxMind sign up

The screen will display the license number that needs to be saved - then it will not be possible to see it, just write out a new license:

MaxMind sign up

And put your licence key to maxmind_key into your group settings:

MaxMind sign up

Go to UP

Start to use GeoLite2 with HAProxy-WI

HAProxy-WI provides to you ability to use GeoLite2 via web interface. Before using GeoLite2 Licence key must be created.

After you have created the Licence key and added it into the group settings you can start using GeoLite2 Database:

Chose a server for uploading, HAProxy-WI will show, if there is GeoLite2(in the black box), and press the "Install" button(in the green box).

HAProxy-WI will download and format it from GeoIP to acceptable format for HAProxy service. Also HAProxy-WI will separate IPs range from one file to single files by country, e.g.: file AD.subnets consists all IPs which uses in Andora.

Go to UP

Updating GeoLite2 with HAProxy-WI

Updating

MaxMind updates GeoLite2 databases every Tuesday, so it should be updated every week. HAProxy-WI can do it! Just check "Updating" checkbox.

Go to UP

Using GeoLite2 with HAProxy

Example of usage of the subnet per continent files we have before downloaded would be creating the following ACLs:

acl acl_AF src -f AF.txt
acl acl_AN src -f AN.txt
acl acl_AS src -f AS.txt
acl acl_EU src -f EU.txt
acl acl_NA src -f NA.txt
acl acl_OC src -f OC.txt
acl acl_SA src -f SA.txt
            

and then using them to allow or decline clients based on the continent they come from, for instance:

http-request deny if !acl_AF
            

or send them to different backend servers:

use_backend bk_af if acl_AN
            
Go to UP