Welcome! Log In Create A New Profile

Advanced

Handling cities with the same name using the GeoIP module

November 12, 2021 09:21AM
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
Subject Author Posted

Handling cities with the same name using the GeoIP module

YvorL November 12, 2021 09:21AM

Re: Handling cities with the same name using the GeoIP module

Maxim Dounin November 12, 2021 09:58AM

Re: Handling cities with the same name using the GeoIP module

YvorL November 14, 2021 12:54PM

Re: Handling cities with the same name using the GeoIP module

Maxim Dounin November 14, 2021 04:26PM

Re: Handling cities with the same name using the GeoIP module

YvorL November 15, 2021 08:46AM

Re: Handling cities with the same name using the GeoIP module

Maxim Dounin November 15, 2021 10:14AM

Re: Handling cities with the same name using the GeoIP module

YvorL November 15, 2021 10:26AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 68
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready