{"id":19505733,"url":"https://github.com/thinker0/mod_geoip2","last_synced_at":"2025-07-13T02:09:06.944Z","repository":{"id":2259576,"uuid":"3215234","full_name":"thinker0/mod_geoip2","owner":"thinker0","description":"Maxmid mod_geoip2","archived":false,"fork":false,"pushed_at":"2012-01-19T05:01:38.000Z","size":104,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-25T22:15:28.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://maxmind.com","language":"C","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/thinker0.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-19T04:59:13.000Z","updated_at":"2013-10-22T20:19:31.000Z","dependencies_parsed_at":"2022-09-02T03:40:47.276Z","dependency_job_id":null,"html_url":"https://github.com/thinker0/mod_geoip2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thinker0/mod_geoip2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinker0%2Fmod_geoip2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinker0%2Fmod_geoip2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinker0%2Fmod_geoip2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinker0%2Fmod_geoip2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinker0","download_url":"https://codeload.github.com/thinker0/mod_geoip2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinker0%2Fmod_geoip2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265080256,"owners_count":23708121,"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-11-10T22:33:45.435Z","updated_at":"2025-07-13T02:09:06.904Z","avatar_url":"https://github.com/thinker0.png","language":"C","readme":"\t\t\t\tmod_geoip2 1.2.7\n\t\t\t\t----------------\n\n======== OVERVIEW =========\n\nmod_geoip2 is an Apache 2.x module for finding the country and city\nthat a web request originated from.  It uses the GeoIP library and\ndatabase to perform the lookup.  It is free software, licensed under\nthe Apache license.  It requires the C API, version 1.4.3 and above, see:\nhttp://www.maxmind.com/app/c\n\nFor the Apache 1.3 mod_geoip module, see:\nhttp://www.maxmind.com/download/geoip/api/mod_geoip/\n\n======== USAGE ============\n\nTo use, see the instructions in INSTALL on how to install the module,\nthen make sure that\n\n  GeoIPEnable On\n\nis set in your Apache configuration file.  This will call the GeoIP Country\ndatabase from its default location (e.g. /usr/local/share/GeoIP/GeoIP.dat)\n\nIf you want to specify the a non-default location for the database file(s),\nor what to use other databases besides GeoIP Country, or to pass options,\nuse:\n\n  GeoIPDBFile /path/to/GeoIP.dat GeoIPFlag\n\nFor example\n\nGeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat MemoryCache\nGeoIPDBFile /usr/local/share/GeoIP/GeoIPOrg.dat Standard\n\nThe possible values for GeoIPFlag are:\n\nThe default GeoIPFlag is Standard, which does not perform\nany memory caching (it is the most memory efficient).  To turn\non memory caching (warning can be memory intensive since\nit is used across all Apache children) use:\n\n  GeoIPDBFile /path/to/GeoIP.dat MemoryCache\n\nWe recommend that you use Memory Caching only for the smaller\ndatabase files, such as GeoIP Country and GeoIP ISP.\n\nAnother MemoryCache option is MMapCache.\n\nIf you would like to enable checking for GeoIP updates, use\n\n  GeoIPDBFile /path/to/GeoIP.dat CheckCache\n\nBefore making a call to the database, geoip will check the GeoIP.dat file\nto see if there is an updated database before making the call.  This way\nyou shouldn't have to restart the Apache server after updating the GeoIP\ndata files.\n\nIf you would like to turn on partial memory caching, use:\n\n  GeoIPDBFile /path/to/GeoIP.dat IndexCache\n\nThe IndexCache option caches the most frequently accessed index portion of\nthe database, resulting in faster lookups than StandardCache, but less\nmemory usage than MemoryCache - useful for larger databases such as\nGeoIP Organization and GeoIP City.  Note, for GeoIP Country, Region\nand Netspeed databases, IndexCache is equivalent to MemoryCache.\n\nCurrently, multiple GeoIPFlags options can not be combined.  This\ncan be fixed by changing geoip_set_filename to ITERATE2, patches welcome.\n\nYou may change the output charset fom latin1 ( iso-8859-1 ) to utf8 with:\n\n  GeoIPEnableUTF8 On\n\n\nOutput variables set:\n\nGEOIP_ADDR is the address used to calculate the geoip information. Either the ipaddress you came \nfrom, or if you use GeoIPScanProxyHeaders On,  the first defined environment \nvariable HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, the http header X-Forwarded-For or the environment \nvariable HTTP_REMOTE_ADDR.\n\nGEOIP_ADDR is always exported, when mod_geoip is used.\n\n\nGeoIP Country Edition:\nYou can retrieve the ISO 3166 Country code from the Apache notes table\nunder the \"GEOIP_COUNTRY_CODE\" key, or from the environment variable\n\"GEOIP_COUNTRY_CODE\". \nYou can also retrieve the Continent code from the \"GEOIP_CONTINENT_CODE\" note or environment variable.\nPossible continent codes are AF, AS, EU, NA, OC, SA for Africa, Asia, Europe, North America, Oceania\nand South America.\nIt also sets the GEOIP_COUNTRY_NAME note and\nenvironment variable.  If GeoIP does not determine the country\nfor an IP address (for example if the IP address is missing\nor is a private IP address), then it will not set the\nGEOIP_COUNTRY_CODE and GEOIP_COUNTRY_NAME variables.\n\nGeoIP Region Edition:\nSets GEOIP_COUNTRY_CODE, GEOIP_REGION_NAME and GEOIP_REGION\n\nGeoIP City Edition:\nSets GEOIP_CONTINENT_CODE, GEOIP_COUNTRY_CODE, GEOIP_REGION, \n\tGEOIP_REGION_NAME, GEOIP_CITY, GEOIP_METRO_CODE,\n        GEOIP_AREA_CODE, GEOIP_LATITUDE, GEOIP_LONGITUDE\n\tand GEOIP_POSTAL_CODE\n\nGeoIP ISP Edition:\nSets GEOIP_ISP\n(Note to ISP edition subscribers, requires new format)\n\nGeoIP Organization Edition:\nSets GEOIP_ORGANIZATION\n\nGeoIP Netspeed Edition:\nSets GEOIP_NETSPEED\n\nGeoIPv6 Edition ( experimental )\nSets GEOIP_CONTINENT_CODE_V6, GEOIP_COUNTRY_CODE_V6,\n        GEOIP_COUNTRY_NAME_V6\n\nBy default it sets both the notes table and environment variable.\nFor performance reasons you may want to only set the one you use, to\ndo so use the \"GeoIPOutput\" configuration directive:\n\n  GeoIPOutput Notes   # Sets Apache notes table only\n  GeoIPOutput Env     # Sets Environmental Variable only\n  GeoIPOutput All     # Sets both (current default behaviour)\n\n========= redirection with mod_geoip and mod_rewrite ========\n\nBelow is an example of how to do redirection with mod_geoip and\nmod_rewrite:\n\nGeoIPEnable On\nGeoIPDBFile /path/to/GeoIP.dat\n\nRewriteEngine on\nRewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$\nRewriteRule \\.(gif|jpg|png|css)$ - [L] # don't redirect images and stylesheets\nRewriteRule ^(.*)$ http://www.canada.com [L] # redirect everything else\n\n======== Blocking unwanted countries ==========\n\n# This blocks traffic from China and Russia\n\nGeoIPEnable On\nGeoIPDBFile /path/to/GeoIP.dat\n\nSetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry\nSetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry\n# ... place more countries here\n\nDeny from env=BlockCountry\n\n# Optional - use if you want to allow a specific IP address from the country you denied\n# See http://httpd.apache.org/docs/1.3/mod/mod_access.html for more details\n# Allow from 10.1.2.3\n\n========= proxies =========\n\nIf you have a backend server in front of a proxy server, and the client IP is in\nthe HTTP_X_FORWARDED_FOR variable, then use\n\nGeoIPScanProxyHeaders On\n\nThis only works if the first IP in the HTTP_X_FORWARDED_FOR list is the\nactual clientIP that you want to lookup.\n\nGeoIPUseLastXForwardedForIP On\n\nUse the last IP from the HTTP_X_FORWARDED_FOR header instead of the first one.\nGeoIPScanProxyHeaders must be enabled ( On ) otherwise\nGeoIPUseLastXForwardedForIP is ignored.\n\n========= Server vs Directory context =========\n\nAll directives expect GeoIPEnable are server config only.\nie: you type it only once per server config. Otherwise the latest wins.\n\n\u003cIfModule mod_geoip.c\u003e\n  GeoIPEnable Off\n  GeoIPEnableUTF8 On\n  GeoIPOutput Env\n  GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat MemoryCache\n  GeoIPDBFile /usr/local/share/GeoIP/GeoIPCity.dat MemoryCache\n  GeoIPDBFile /usr/local/share/GeoIP/GeoIPOrg.dat MemoryCache\n\u003c/IfModule\u003e\n\nGeoIPEnable is useful in server or directory context. For example:\n\n##\n## Example 1 GeoIP is only avail for creation parts of our server\n##\n\n\u003cIfModule mod_geoip.c\u003e\n  GeoIPEnable Off\n  GeoIPEnableUTF8 On\n  GeoIPOutput Env\n  GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat MemoryCache\n\u003c/IfModule\u003e\n\n# GeoIP information is avail only inside /xxx\n\u003cLocation /xxx\u003e\n  GeoIPEnable On\n\u003c/Location\u003e\n\n\n\n##\n## Example 2 GeoIP is avail for every request\n##\n\n\u003cIfModule mod_geoip.c\u003e\n  GeoIPEnable On\n  GeoIPEnableUTF8 On\n  GeoIPOutput Env\n  GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat MemoryCache\n\u003c/IfModule\u003e\n\n\u003cLocation /xxx\u003e\n  GeoIPEnable On\n\u003c/Location\u003e\n\n## geoip information is also avail inside /yyy since it is enabled serverwide!!!\n\u003cLocation /yyy\u003e\n  GeoIPEnable Off\n\u003c/Location\u003e\n\n======== preformance -- getting fast =======\n\nTo get really fast, add the MemoryCache option to the GeoIPDBFile directive or\nthe MMapCache with very similar results.\n\n========= saving memory =========\n\nEvery apache child share the same database over all childs.\nFrom mod_geoip version 1.2.1 on. If you choice to use MemoryCache or MMapCache.\nDoing so reduce the child database loading time to zero and the memoryusage\nis about the database filesize. No matter how many childs apache spawns. The\nonly thing to remember is ask apache to update, if your the database change. \nUse httpd -k graceful to do so without stopping apache.\n\n========= performance =====\n\nFor improved performance, you may want to only enable mod_geoip\nfor specific HTML pages.  If you want to use the mod_geoip module\nsite-wide, you may still be able to only use it for HTML pages\nand not images.  To restrict the pages where mod_geoip is used,\nplace the GeoIPEnable on and associated directives inside a\n\u003cLocation\u003e, \u003cFiles\u003e or \u003cFilesMatch\u003e directive, see:\nhttp://httpd.apache.org/docs/2.0/sections.html\n\n========= troubleshooting =======\n\nIf the module is not working, make sure that the httpd user (e.g. nobody)\nhas read access to the GeoIP.dat file, by running the chown or chmod command.\n\nIf the GeoIP variables do not show up, please make sure that the client\nIP address is not on a private network such as 10.0.0.0/8, 172.16.0.0/12\nor 192.168.0.0/16.  GeoIP only reports the country of external IP addresses.\n\n========= Copyright =========\n\nCopyright 2007 MaxMind LLC\nsupport@maxmind.com\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinker0%2Fmod_geoip2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinker0%2Fmod_geoip2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinker0%2Fmod_geoip2/lists"}