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-07-23 02:00 UTC
IP Ranges: 309,555
Country Codes: 238
SHA-256 checksum: 26c0e579210f0e74c30d3df56448cb07d7b8fc4958f4148391947c7a22c6ee24