Using IPinfo's data in HAProxy

HAProxy Enterprise provides native MaxMind/IPinfo MMDB support through its built-in MaxMind module. This allows the user to query any field in an MMDB file directly within HAProxy using the maxmind-lookup function.

For example, ACLs (Access Control List) can be defined based on country, city, ASN, or any other database field, and used to block traffic, route requests, or add headers. This approach is fully integrated, high-performance, and works with generic MMDBs, including any IPinfo databases as long as they are MMDB.

For HAProxy Community Edition, native MMDB support does not exist. Not for IPinfo and Not for MaxMind.

To achieve similar functionality, a common approach is to use a small backend lookup service written in Python or Go that loads the MMDB and exposes a local HTTP API. HAProxy Community can then call this service via Lua scripts to fetch geolocation information for the client IP.

This allows the user to work with any generic MMDB, including IPinfo databases, and implement ACLs, logging, or routing based on the returned country, ASN, or other fields. While this is not fully native, it is robust and compatible with large MMDBs.

Using Lua directly to read an MMDB in HAProxy Community Edition is theoretically possible, but in practice it’s limited and risky. Hence why you have libraries like this: GitHub - O-X-L/haproxy-geoip: HAProxy (community) GeoIP Lookups that has a dedicated HTTP service to server the MMDB written in Go and Python.

Most Lua MMDB libraries are designed for OpenResty/LuaJIT, not the stock Lua interpreter that HAProxy uses, which can cause compatibility and memory issues, especially with large databases.

Reading and parsing the MMDB on every request can also block HAProxy’s event loop, reducing performance under load. By contrast, a small backend service written in Python or Go can keep the MMDB in memory, handle lookups efficiently, and expose a simple HTTP API that HAProxy Lua scripts call. This approach is more robust, allows daily MMDB updates without restarting HAProxy, and works reliably with any generic MMDB, including IPinfo Lite, whereas native Lua-only solutions are brittle and harder to maintain.

For Enterprise, the recommended approach is to use HAProxy’s native MaxMind module and maxmind-lookup, which provides a fully integrated and high-performance solution for any MMDB including IPinfo’s MMDB.

For Community Edition, the most reliable approach is to deploy a local backend service combined with HAProxy Lua scripts, which allows generic MMDB usage while enabling geolocation-based ACLs and routing.

Both approaches support generic IPinfo databases, but Enterprise eliminates the need for external services and Lua scripting, making it simpler to maintain and scale.