HAProxy Enterprise Documentation 2.8r1

Use converters to perform database lookups

Use the converter maxmind-lookup to perform a lookup in the database that returns the values of the specified property. Properties in the MaxMind database are stored hierarchically. For example, you can find the name of a city in English at city > names > en.

Syntax:

maxmind-lookup(<db_type>,<prop-level1>[,<prop-level2>*])

In this example we set HTTP request headers that contain CITY and ISP properties based on client's source IP address.

frontend www
    bind :80
    mode http
    http-request add-header X-CityName  %[src,maxmind-lookup("CITY","city","names","en")]
    http-request add-header X-ISOCode   %[src,maxmind-lookup("CITY","country","iso_code")]
    http-request add-header X-ASN       %[src,maxmind-lookup("ISP","autonomous_system_number")]
    http-request add-header X-ASNOrg    %[src,maxmind-lookup("ISP","autonomous_system_organization")]

Next up

Update the database during runtime