{"id":21945917,"url":"https://github.com/ip2location/ip2proxy-nginx","last_synced_at":"2025-04-22T21:27:01.089Z","repository":{"id":46517839,"uuid":"91553162","full_name":"ip2location/ip2proxy-nginx","owner":"ip2location","description":"A IP2Proxy module for Nginx HTTP server.","archived":false,"fork":false,"pushed_at":"2025-02-12T06:56:33.000Z","size":44,"stargazers_count":28,"open_issues_count":0,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-18T21:16:50.600Z","etag":null,"topics":["http-server","ip-address","ip2proxy","ip2proxy-nginx","nginx","open-proxies","proxy-data","proxy-information","proxy-server","tor","vpn"],"latest_commit_sha":null,"homepage":null,"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":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}},"created_at":"2017-05-17T08:37:10.000Z","updated_at":"2025-04-07T20:38:32.000Z","dependencies_parsed_at":"2024-02-19T02:44:49.851Z","dependency_job_id":"8f483690-2f6a-4e0a-9d54-0473942703d0","html_url":"https://github.com/ip2location/ip2proxy-nginx","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2proxy-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2proxy-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2proxy-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2proxy-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ip2location","download_url":"https://codeload.github.com/ip2location/ip2proxy-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250326998,"owners_count":21412358,"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":["http-server","ip-address","ip2proxy","ip2proxy-nginx","nginx","open-proxies","proxy-data","proxy-information","proxy-server","tor","vpn"],"created_at":"2024-11-29T04:20:13.504Z","updated_at":"2025-04-22T21:27:01.083Z","avatar_url":"https://github.com/ip2location.png","language":"C","readme":"# Nginx IP2Proxy module\n\n\n\n### Description\n\nThe Nginx IP2Proxy module enables user to detect visitor IP addresses which are used as VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges, residential proxies, consumer privacy networks, and enterprise private networks.\n\nThe IP2Proxy database can be downloaded from [https://lite.ip2location.com](https://lite.ip2location.com/ip2proxy-lite) (Free) or [https://www.ip2location.com](https://www.ip2location.com/database/ip2proxy) (Commercial).\n\n\n\n### Installation\n\n1. Download IP2Proxy C library from https://github.com/ip2location/ip2proxy-c.\n\n2. Compile and install IP2Proxy C library.\n\n3. Download IP2Proxy module and decompress the package.\n\n   ```bash\n   wget https://github.com/ip2location/ip2proxy-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-ip2proxy-master\n   make\n   make install\n   ```\n\n   **Dynamic Module**\n\n   ```bash\n   ./configure --add-dynamic-module=/absolute/path/to/nginx-ip2proxy-master\n   make\n   make install\n   ```\n\n\n\n### Nginx Configuration\n\nInsert the configuration below to your `nginx.conf`.\n\n```\nSyntax      : load_module modules/ngx_http_ip2proxy_module.so;\nDefault     : -\nContext     : main\nDescription : Load IP2Proxy Nginx module if it was compiled as dynamic.\n```\n\n```\nSyntax      : ip2proxy_database path\nDefault     : none\nContext     : http\nDescription : The absolute path to IP2Proxy BIN database.\n```\n\n```\nSyntax      : ip2proxy_proxy_recursive on|off\nDefault     : off\nContext     : http\nDescription : Enable recursive search in the x-forwarded-for headers.\n```\n\n```\nSyntax      : ip2proxy_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\n\tip2proxy_database\t\t\t/usr/share/ip2location/PX3.BIN;\n\tip2proxy_proxy_recursive\ton;\n\tip2proxy_proxy\t\t\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$ip2proxy_country_short;\n$ip2proxy_country_long;\n$ip2proxy_region;\n$ip2proxy_city;\n$ip2proxy_isp;\n$ip2proxy_is_proxy;\n$ip2proxy_proxy_type;\n$ip2proxy_domain;\n$ip2proxy_usage_type;\n$ip2proxy_proxy_asn;\n$ip2proxy_proxy_as;\n$ip2proxy_last_seen;\n$ip2proxy_threat;\n$ip2proxy_provider;\n$ip2proxy_fraud_score;\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 $ip2proxy_country_short;\n\t\tadd_header X-Country-Name $ip2proxy_country_long;\n\n\t\tfastcgi_param IP2PROXY_COUNTRY_SHORT\t$ip2proxy_country_short;\n\t\tfastcgi_param IP2PROXY_COUNTRY_LONG\t$ip2proxy_country_long;\n\t\tfastcgi_param IP2PROXY_REGION\t\t$ip2proxy_region;\n\t\tfastcgi_param IP2PROXY_CITY\t\t$ip2proxy_city;\n\t\tfastcgi_param IP2PROXY_ISP\t\t$ip2proxy_isp;\n\t\tfastcgi_param IP2PROXY_IS_PROXY\t\t$ip2proxy_is_proxy;\n\t\tfastcgi_param IP2PROXY_PROXY_TYPE\t$ip2proxy_proxy_type;\n\t\tfastcgi_param IP2PROXY_DOMAIN\t\t$ip2proxy_domain;\n\t\tfastcgi_param IP2PROXY_USAGE_TYPE\t$ip2proxy_usage_type;\n\t\tfastcgi_param IP2PROXY_PROXY_ASN\t$ip2proxy_proxy_asn;\n\t\tfastcgi_param IP2PROXY_PROXY_AS\t\t$ip2proxy_proxy_as;\n\t\tfastcgi_param IP2PROXY_LAST_SEEN\t$ip2proxy_last_seen;\n\t\tfastcgi_param IP2PROXY_THREAT\t\t$ip2proxy_threat;\n\t\tfastcgi_param IP2PROXY_PROVIDER\t\t$ip2proxy_provider;\n\t\tfastcgi_param IP2PROXY_FRAUD_SCORE\t$ip2proxy_fraud_score;\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 Proxy IP\n\n```nginx\nif ( $ip2proxy_is_proxy = '1' ) {\n    return 444;\n}\n```\n\n\n\n##### Block Spammers\n\n```nginx\nif ( $ip2proxy_threat = 'SPAM' ) {\n    return 444;\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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2proxy-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fip2location%2Fip2proxy-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2proxy-nginx/lists"}