geo: replace ip-api.com with local DB-IP City Lite MMDB

- Rewrite nginxmon/geo.py to use maxminddb + DB-IP City Lite MMDB
  (https://cdn.jsdelivr.net/npm/dbip-city-lite/dbip-city-lite.mmdb.gz)
  instead of ip-api.com HTTP API — eliminates all network timeouts and
  rate-limit issues; lookups are now sub-millisecond in-process
- Keep _lookup_batch() signature unchanged so routermon receiver
  requires no changes
- MMDB downloaded on first use (lazy) and refreshed monthly via
  APScheduler; reader cached module-level (thread-safe for reads)
- Add management command: manage.py download_geo_db
- Update k8s init container to download MMDB on first deploy if absent
- Add maxminddb==3.1.1 dependency

CC BY 4.0 — DB-IP (https://db-ip.com)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-04-16 16:44:02 +10:00
co-authored by Copilot
parent c66295cb87
commit 3955e95b9e
6 changed files with 201 additions and 18 deletions
+1
View File
@@ -27,6 +27,7 @@ dependencies = [
"qdrant-client>=1.13.2",
"cryptography>=42.0.0",
"kubernetes>=29.0.0",
"maxminddb>=3.1.1",
]
[build-system]