HAProxy Geo-IP
A Geo-IP file is available to download that is updated twice daily (02:00 UTC and 14:00 UTC) for use with HAProxy.
This is very similar to another source, but that file was an incomplete list. This file also includes both IPv4 and IPv6 addresses.
This file can be used to append the country code to the HAProxy log file using something similar to the following configuration:
log-format "%ci:%cp_%[src,map_ip(/etc/haproxy/haproxy_geo_ip.txt)] [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"
This file can also be used to block connections to HAProxy from a user with an IP from a certain country using something similar to the following configuration:
acl acl_geoloc_block src,map_ip(/etc/haproxy/haproxy_geo_ip.txt) -m reg -i (RU|IR)
http-request silent-drop if acl_geoloc_block
Download the haproxy_geo_ip.txt file (5.5 MB)
File updated at 2024-04-24 02:00 UTC
IP Ranges: 306,935
Country Codes: 238
SHA-256 checksum: e5541a4bd776293c5c58be04018ea4d421a653a0792ce078f9c87380a8e1557f