{"id":21945937,"url":"https://github.com/ip2location/ip2location-nginx","last_synced_at":"2025-08-30T02:04:49.797Z","repository":{"id":62929287,"uuid":"78709857","full_name":"ip2location/ip2location-nginx","owner":"ip2location","description":"This is IP2Location Nginx module that enables the user to find the country, region (state), city, latitude, longitude, zip code, time zone, ISP, domain name, connection type, area code, weather, mobile network, elevation, usage type, address type and IAB category by IP address or hostname originates from.","archived":false,"fork":false,"pushed_at":"2024-01-03T05:57:09.000Z","size":50,"stargazers_count":68,"open_issues_count":0,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-23T10:59:44.394Z","etag":null,"topics":["geolocation","ip-address-location","ip-database","ip-geolocation","ip-lookup","ip2location","nginx"],"latest_commit_sha":null,"homepage":"http://www.ip2location.com","language":"C","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/ip2location.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","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":"2017-01-12T04:52:45.000Z","updated_at":"2025-07-13T00:13:29.000Z","dependencies_parsed_at":"2024-01-03T06:40:04.048Z","dependency_job_id":"9fcdf4f0-806d-44dd-8a3f-7a4e328bb21e","html_url":"https://github.com/ip2location/ip2location-nginx","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ip2location/ip2location-nginx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ip2location","download_url":"https://codeload.github.com/ip2location/ip2location-nginx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-nginx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272793018,"owners_count":24993830,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["geolocation","ip-address-location","ip-database","ip-geolocation","ip-lookup","ip2location","nginx"],"created_at":"2024-11-29T04:20:27.011Z","updated_at":"2025-08-30T02:04:49.774Z","avatar_url":"https://github.com/ip2location.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nginx IP2Location module\n\n\n\n### Description\n\nThe Nginx IP2Location module enables user to easily perform client's IP to geographical location lookup by using IP2Location database.\n\nThe IP2Location database can be downloaded from https://lite.ip2location.com (Free) or https://www.ip2location.com (Commercial).\n\n\n\n### Installation\n\n1. Download IP2location C library from https://github.com/chrislim2888/IP2Location-C-Library\n\n2. Compile and install IP2Location C library.\n\n3. Download IP2Location module and decompress the package.\n\n   ```bash\n   wget https://github.com/ip2location/ip2location-nginx/archive/master.zip\n   unzip master.zip\n   rm master.zip\n   ```\n\n   \n\n4. Download the latest Nginx source code from https://nginx.org/en/download.html\n\n   ```bash\n   wget https://nginx.org/download/nginx-x.y.z.tar.gz\n   ```\n\n   \n\n5. Decompress and go into Nginx source directory.\n\n   ```bash\n   tar xvfz nginx-x.y.z.tar.gz\n   cd nginx-x.y.z\n   ```\n\n   \n\n6. Re-compile Nginx from source to include this module.\n\n   **Static Module**\n\n   ```bash\n   ./configure --add-module=/absolute/path/to/nginx-ip2location-master\n   make\n   make install\n   ```\n\n   **Dynamic Module**\n\n   ```bash\n   ./configure --add-dynamic-module=/absolute/path/to/nginx-ip2location-master\n   make\n   make install\n   ```\n\n### Nginx Configuration\n\nInsert the configuration below to your `nginx.conf`.\n\n```\nSyntax      : load_module modules/ngx_http_ip2location_module.so;\nDefault     : -\nContext     : main\nDescription : Load IP2Location Nginx module if it was compiled as dynamic.\n```\n\n```\nSyntax      : ip2location_database path\nDefault     : none\nContext     : http\nDescription : The absolute path to IP2Location BIN database.\n```\n\n```\nSyntax      : ip2location_proxy_recursive on|off\nDefault     : off\nContext     : http\nDescription : Enable recursive search in the x-forwarded-for headers.\n```\n\n```\nSyntax      : ip2location_proxy cidr|address\nDefault     : none\nContext     : http\nDescription : Set a list of proxies to translate x-forwarded-for headers for.\n```\n\n\n\n**Example:**\n\n```nginx\nhttp {\n\t...\n\t\n\tip2location_database\t\t/usr/share/ip2location/DB6.BIN;\n\tip2location_proxy_recursive\ton;\n\tip2location_proxy\t\t192.168.1.0/24;\n}\n```\n\n\n\n### Variables\n\nThe following variables will be made available in Nginx:\n\n```nginx\n$ip2location_country_short\n$ip2location_country_long\n$ip2location_region\n$ip2location_city\n$ip2location_isp\n$ip2location_latitude\n$ip2location_longitude\n$ip2location_domain\n$ip2location_zipcode\n$ip2location_timezone\n$ip2location_netspeed\n$ip2location_iddcode\n$ip2location_areacode\n$ip2location_weatherstationcode\n$ip2location_weatherstationname\n$ip2location_mcc\n$ip2location_mnc\n$ip2location_elevation\n$ip2location_usagetype\n$ip2location_addresstype\n$ip2location_category\n$ip2location_district\n$ip2location_asn\n$ip2location_as\n```\n\n\n\n### Usage Example\n\n##### Add Server Variables\n\n```nginx\nserver {\n\tlisten 80 default_server;\n\troot /var/www;\n\tindex index.html index.php;\n\n\taccess_log /var/log/nginx/access.log;\n\terror_log /var/log/nginx/error.log;\n\n\tserver_name _;\n\n\tlocation / {\n\t\ttry_files $uri $uri/ =404;\n\t}\n\n\tlocation ~ \\.php$ {\n\t\tfastcgi_pass php-fpm-sock;\n\t\tfastcgi_index index.php;\n\t\tinclude fastcgi.conf;\n\n\t\t# Add custom header to view result in HTTP response\n\t\tadd_header X-Country-Code $ip2location_country_short;\n\t\tadd_header X-Country-Name $ip2location_country_long;\n\n\t\tfastcgi_param IP2LOCATION_COUNTRY_SHORT       $ip2location_country_short;\n\t\tfastcgi_param IP2LOCATION_COUNTRY_LONG        $ip2location_country_long;\n\t\tfastcgi_param IP2LOCATION_REGION              $ip2location_region;\n\t\tfastcgi_param IP2LOCATION_CITY                $ip2location_city;\n\t\tfastcgi_param IP2LOCATION_ISP                 $ip2location_isp;\n\t}\n}\n```\n\n**Notes:** Restart Nginx and view your server response header to confirm the variables are added.\n\n\n\n##### Block Single Country\n\n```nginx\nif ( $ip2location_country_short = 'US' ) {\n    return 444;\n}\n```\n\n\n\n##### Block Multiple Countries\n\n```nginx\nmap $ip2location_country_short $blacklist_country {\n\tdefault no;\n\tAU yes;\n\tIN yes;\n\tNG yes;\n}\n\nserver {\n    ...\n        \n\tif ( $blacklist_country = yes ) {\n\t\treturn 444;\n\t}\n}\n```\n\n\n\n### IPv4 BIN vs IPv6 BIN\n\nUse the IPv4 BIN file if you just need to query IPv4 addresses.\n\nIf you query an IPv6 address using the IPv4 BIN, you'll see the INVALID_IP_ADDRESS error.\n\nUse the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.\n\n\n\n### Support\nPlease visit us at https://www.ip2location.com for services and databases we offer.\n\nFor support, please email us at support@ip2location.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fip2location%2Fip2location-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-nginx/lists"}