{"id":17700534,"url":"https://github.com/cdown/geoip-http","last_synced_at":"2025-05-07T13:05:20.249Z","repository":{"id":168487629,"uuid":"644212437","full_name":"cdown/geoip-http","owner":"cdown","description":"GeoIP lookup server over HTTP.","archived":false,"fork":false,"pushed_at":"2025-02-12T00:18:29.000Z","size":139,"stargazers_count":8,"open_issues_count":7,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T13:05:12.509Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdown.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-23T03:56:08.000Z","updated_at":"2025-04-16T16:27:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"a54f9ff3-272f-4b93-abfd-12d518268c51","html_url":"https://github.com/cdown/geoip-http","commit_stats":{"total_commits":113,"total_committers":3,"mean_commits":"37.666666666666664","dds":"0.35398230088495575","last_synced_commit":"96f06c1aaaaf7fa2a452ef3aa09b58a4dae2035a"},"previous_names":["cdown/tzserver"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdown%2Fgeoip-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdown%2Fgeoip-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdown%2Fgeoip-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdown%2Fgeoip-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdown","download_url":"https://codeload.github.com/cdown/geoip-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883215,"owners_count":21819160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-24T17:42:29.062Z","updated_at":"2025-05-07T13:05:20.222Z","avatar_url":"https://github.com/cdown.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# geoip-http | [![Tests](https://img.shields.io/github/actions/workflow/status/cdown/geoip-http/ci.yml?branch=master)](https://github.com/cdown/geoip-http/actions?query=branch%3Amaster)\n\ngeoip-http is a fast GeoIP lookup service in Rust, using the\n[Axum](https://docs.rs/axum/latest/axum/) web framework. It provides one\npossible server for [tzupdate](https://github.com/cdown/tzupdate).\n\n## Features\n\n- Fast, uses Axum web framework\n- Simple, less than 300 lines of code\n- Safe hot reload of GeoIP DB without restarting\n- Correct cache behaviour for implicit/explicit IP lookup\n- Direct dump of GeoIP data: no filtering\n- Support for both explicit and implicit (client IP) queries\n- Support for X-Forwarded-For, X-Real-IP, CloudFront, etc\n- Sequence based logging for debugging\n\n## Usage\n\nDownload GeoLite2-City.mmdb from\n[here](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data/), and\nextract it.\n\nBy default, the server runs on TCP 0.0.0.0:3000. You can change this with the\n`--ip` and `--port` options. You can also set the GeoIP database file location\nwith the `--db` option.\n\nYou can then query `/` to get data for the connecting IP (respecting things\nlike X-Real-IP, X-Forwarded-For, and the like), or `/8.8.8.8` to get details\nfor (for example) 8.8.8.8:\n\n```\n% curl --silent http://127.0.0.1:3000/8.8.8.8 | jq '.location'\n{\n  \"accuracy_radius\": 5,\n  \"latitude\": 34.0544,\n  \"longitude\": -118.2441,\n  \"metro_code\": 803,\n  \"time_zone\": \"America/Los_Angeles\"\n}\n```\n\nThe format matches that of the maxminddb crate's [City\nstruct](https://docs.rs/maxminddb/latest/maxminddb/geoip2/struct.City.html),\nrepresented as JSON by its `Serialize` trait.\n\n## Logging\n\nTo see debug info, run with `RUST_LOG=geoip_http=debug,tower_http=debug`.\n\n## Rate limiting\n\ngeoip-http is designed to be run behind a local reverse proxy, so rate limiting\ngenerally should happen there. It can also be added via\n[tower-governor](https://github.com/benwis/tower-governor).\n\n## Performance\n\nOn my T14s Gen 2:\n\n    % wrk -t\"$(nproc)\" -c400 -d30s http://127.0.0.1:3000/8.8.8.8\n    Running 30s test @ http://127.0.0.1:3000/8.8.8.8\n      8 threads and 400 connections\n      Thread Stats   Avg      Stdev     Max   +/- Stdev\n        Latency     1.28ms    1.11ms  29.11ms   87.45%\n        Req/Sec    42.99k    10.07k  158.55k    75.56%\n      10269395 requests in 30.09s, 1.44GB read\n    Requests/sec: 341246.16\n    Transfer/sec:     49.14MB\n\n## Example server config\n\n### Nginx proxy config\n\nFill in `ssl_certificate` and `ssl_certificate_key`.\n\n```\nhttp {\n    limit_conn_zone $binary_remote_addr zone=geoip_conn_limit:2m;\n    limit_req_zone $binary_remote_addr zone=geoip_rate_limit:2m rate=100r/m;\n\n    upstream geoip-backend {\n        server 127.0.0.1:3000;\n        keepalive 16;\n    }\n\n    server {\n        listen 80;\n        listen [::]:80;\n        server_name geoip.chrisdown.name;\n\n        client_body_timeout 2s;\n        client_header_timeout 2s;\n\n        location / {\n            limit_req zone=geoip_rate_limit;\n            limit_conn addr 5;\n            return 301 https://$host$request_uri;\n        }\n    }\n\n    server {\n        listen 443 ssl;\n        listen [::]:443 ssl;\n        server_name geoip.chrisdown.name;\n\n        client_body_timeout 2s;\n        client_header_timeout 2s;\n\n        ssl_certificate ...;\n        ssl_certificate_key ...;\n\n        location / {\n            limit_req zone=geoip_rate_limit;\n            limit_conn addr 50;\n            proxy_pass http://geoip-backend;\n        }\n    }\n}\n```\n\n### Systemd unit for geoip-http\n\nFill in `--db`.\n\n```\n[Service]\nExecStart=/usr/bin/geoip-http --db ...\nExecReload=/usr/bin/curl -v http://127.0.0.1:3000/reload/geoip\nRestart=always\n```\n\n## Attribution\n\nThis product is designed to use GeoLite2 data created by MaxMind, available\nfrom https://maxmind.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdown%2Fgeoip-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdown%2Fgeoip-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdown%2Fgeoip-http/lists"}