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.6 MB)
File updated at 2024-12-03 02:00 UTC
IP Ranges: 312,280
Country Codes: 238
SHA-256 checksum: 09e193965ffc1566697b29f2b1ade2377a2bb8496a919710873194d4fca70abb