Handling cities with the same name using the GeoIP module
YvorL
nginx-forum at forum.nginx.org
Fri Nov 12 14:21:58 UTC 2021
I was setting up GeoIP rules
(https://nginx.org/en/docs/http/ngx_http_geoip_module.html) and looked into
the MaxMind database when I realized there are multiple cities that has the
same name. This means I can't simply match $geoip_city in a rule. The only
data that's unique and is available for all cities in the world is the
"geoname ID" (https://www.geonames.org/). However, it seems I can't use that
field even if it's available in the database file. Also, I don't want to
complicate the code with different approaches for different countries (e.g.,
metro code/DMA region code is only available in the US).
Is there any way I can use that unique ID to identify a specific city in the
Nginx configuration?
If there isn't, what would be the best implementation to avoid multiple
conditionals? Using the module already eats up memory and I'd like to
provide the best experience for the websites.
Examples:
Clinton - 28 cities in the US (naturally all in different states)
Aalst - 2 cities in Belgium (in two different provinces)
Acailandia - 2 cities in Brazil (in two different "subdivision")
...
version: nginx/1.21.3
Thank you,
YvorL
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,292821,292821#msg-292821
More information about the nginx
mailing list