{"id":23104799,"url":"https://github.com/mayniklas/nixos-geoip","last_synced_at":"2025-04-03T22:12:59.699Z","repository":{"id":109060989,"uuid":"585653674","full_name":"MayNiklas/NixOS-GeoIP","owner":"MayNiklas","description":"Easily use GeoIP on NixOS systems","archived":false,"fork":false,"pushed_at":"2023-01-06T09:28:08.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-09T10:09:38.487Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MayNiklas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-05T18:14:48.000Z","updated_at":"2023-01-06T09:25:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"9aeba2e1-d46b-44a1-9a76-9d7989501791","html_url":"https://github.com/MayNiklas/NixOS-GeoIP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2FNixOS-GeoIP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2FNixOS-GeoIP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2FNixOS-GeoIP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2FNixOS-GeoIP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MayNiklas","download_url":"https://codeload.github.com/MayNiklas/NixOS-GeoIP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247086027,"owners_count":20881160,"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-12-17T00:36:25.970Z","updated_at":"2025-04-03T22:12:59.682Z","avatar_url":"https://github.com/MayNiklas.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NixOS-GeoIP\n\nEasily make GeoIP databases available to use with NGINX.\n\nSince I want to use GeoIP on personal as well as work projects, I decided to put this module into it's own flake repository.\nIt might be helpful to others as well.\nCurrently only filtering for Germany is supported; more is planned.\n\n## Usage\n\n### NixOS\n\n1. Add this repository as a flake input to your project:\n\n```nix\n{\n  inputs.GeoIP={\n    url = \"github:MayNiklas/NixOS-GeoIP\";\n    inputs.nixpkgs.follows = \"nixpkgs\";\n  };\n}\n```\n\n2. Enable the service in your configuration.nix:\n\n```nix\n{ GeoIP, ... }: {\n\n  imports = [ GeoIP.nixosModules.geoip ];\n\n  mayniklas.geoip = {\n    enable = true;\n    AccountID = 123456;\n    DatabaseDirectory = \"/var/lib/GeoIP\";\n    LicenseKey = \"/var/src/secrets/maxmind/maxmind_license_key\";\n  };\n}\n```\n\n\n3. Create the LicenseKey file and add your license key to it:\n\n```bash\nsudo mkdir -p /var/src/secrets/maxmind\nsudo touch /var/src/secrets/maxmind/maxmind_license_key\nsudo nano /var/src/secrets/maxmind/maxmind_license_key\n```\n\n4. To filter for Germany, configure your virtualHost like this:\n\n```nix\n{\n  services.nginx = {\n    virtualHosts = {\n      ${cfg.hostname} = {\n        enableACME = true;\n        forceSSL = true;\n        locations = {\n          \"/\" = {\n            proxyPass = \"http://127.0.0.1:${toString cfg.port}\";\n            extraConfig = toString ([''\n              proxy_set_header X-Forwarded-Host $http_host;\n              proxy_set_header X-Real-IP $remote_addr;\n              proxy_set_header X-Forwarded-Proto $scheme;\n            ''] ++ optional config.services.geoipupdate.enable ''\n              if ($allowed_country = no) {\n                  return 444;\n              }\n            '');\n          };\n        };\n      };\n    };\n  };\n}\n```\n\nThis will return a 444 status code if a request is made from a country other than Germany.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayniklas%2Fnixos-geoip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayniklas%2Fnixos-geoip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayniklas%2Fnixos-geoip/lists"}