Handling cities with the same name using the GeoIP module

Maxim Dounin mdounin at mdounin.ru
Sun Nov 14 21:23:43 UTC 2021


Hello!

On Sun, Nov 14, 2021 at 12:54:47PM -0500, YvorL wrote:

> I see. It's weird that I can't use a column that's right there in the
> database and would uniquely identify any entry.

That's because there is no such column in the database nginx uses.  
Note that GeoIP modules uses GeoIP databases, not GeoIP2.

> When I checked the Nginx documentation, I saw this:
> "$geoip_region
> two-symbol country region code (region, territory, state, province, federal
> land and the like), for example, “48”, “DC”."
> That should be the "subdivision_1_iso_code" in the database.

That's, literally, "region code" in the database:

https://dev.maxmind.com/geoip/legacy/databases?lang=en#geoip-legacy-city-csv-database-fields

> Meanwhile, when I logged my activity, I saw the name of the region
> (subdivision_1_name) in the logs and when I changed to "$geoip_region_name"
> nothing was logged.

This probably means that GeoIP library provides no meaningful name 
for the region.  Region names are hardcoded in the library, so you 
can check if it's present here:

https://github.com/maxmind/geoip-api-c/blob/1a88de37a1e9001a7207ed2961477634b9efba97/libGeoIP/regionName.c

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list