haproxy-geoip2
haproxy-geoip2 adds MaxMind GeoIP database support to HAProxy 2.8+ Community Edition using Lua API.
It implemented as a native Lua module written in Rust using mlua and haproxy-api crates.
Usage
Please check the module and tests directories for working examples.
local geoip2 = require
geoip2.
The module registers the following converters in HAProxy:
global
master-worker
# If reload_interval is set to a value greater than 0,
# this option is required to enable non-blocking databases loading
insecure-fork-wanted
lua-load-per-thread haproxy.lua
...
listen http-in
bind *:8080
http-request set-var(txn.city) url_param(ip),lua.geoip2-lookup-city("city","names","en")
http-request set-var(txn.asn) url_param(ip),lua.geoip2-lookup-asn("asn")
http-request return status 200 content-type text/plain lf-string "{\"city\":\"%[var(txn.city)]\",\"asn\":\"%[var(txn.asn)]\"}"
License
This project is licensed under the MIT license