I have the following line in my haproxy config:
http-request set-header x-geoip-country %[src,map(/etc/hap1.8/geo/country_iso_code.map)]
to set the country of origin but it only works if the key is the exact key ip and not CIDR notation ips that haproxy expects. the list is from maxmind and its formatted like;
1.0.0.0/24 AU
1.0.1.0/24 CN
1.0.16.0/20 JP
...
for example an ip of 1.0.0.45 would match 1.0.0.45 in the file but not 1.0.0.0/24. While that seems logical, it was in an example on haproxy so I'm asking if its possible to match against 10.0.0.0/24?
By default, map
will match by string, not by ip. From the docs:
map_<match_type>(<map_file>[,<default_value>])
... If the
<match_type>
is not set, it defaults to "str" ...
To match by ip use map_ip
:
http-request set-header x-geoip-country %[src,map_ip(/etc/hap1.8/geo/country_iso_code.map)]