{"id":19459622,"url":"https://github.com/weserv/rate-limit-nginx-module","last_synced_at":"2025-08-26T16:10:23.254Z","repository":{"id":92308977,"uuid":"161040447","full_name":"weserv/rate-limit-nginx-module","owner":"weserv","description":"A Redis backed rate limit module for Nginx web servers.","archived":false,"fork":false,"pushed_at":"2025-01-19T10:19:55.000Z","size":48,"stargazers_count":42,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T07:35:36.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weserv.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,"zenodo":null}},"created_at":"2018-12-09T13:07:21.000Z","updated_at":"2025-03-29T14:44:36.000Z","dependencies_parsed_at":"2025-04-25T07:32:53.777Z","dependency_job_id":"f4ec3b65-e130-48ba-bd8d-ebc5327c3c7e","html_url":"https://github.com/weserv/rate-limit-nginx-module","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/weserv/rate-limit-nginx-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weserv%2Frate-limit-nginx-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weserv%2Frate-limit-nginx-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weserv%2Frate-limit-nginx-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weserv%2Frate-limit-nginx-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weserv","download_url":"https://codeload.github.com/weserv/rate-limit-nginx-module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weserv%2Frate-limit-nginx-module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272235677,"owners_count":24897244,"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-26T02:00:07.904Z","response_time":60,"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":[],"created_at":"2024-11-10T17:33:26.721Z","updated_at":"2025-08-26T16:10:23.186Z","avatar_url":"https://github.com/weserv.png","language":"C","funding_links":[],"categories":["Upstreams, rate limiting and access control"],"sub_categories":[],"readme":"# rate-limit-nginx-module\n\n[![CI status](https://github.com/weserv/rate-limit-nginx-module/workflows/CI/badge.svg)](https://github.com/weserv/rate-limit-nginx-module/actions)\n\nA Redis backed rate limit module for Nginx web servers.\n\nThis implementation is based on the following [Redis module](https://redis.io/topics/modules-intro):\n\n* [redis-rate-limiter](https://github.com/onsigntv/redis-rate-limiter)\n\nWhich offers a straightforward implementation of the fairly sophisticated [generic cell rate algorithm](https://en.wikipedia.org/wiki/Generic_cell_rate_algorithm), in 130 lines of C, without external dependencies.\n\n*This module is not distributed with the Nginx source.*\n\n## Status\n\nThis module is production ready.\n\n## Synopsis\n\n```nginx\nupstream redis {\n   server 127.0.0.1:6379;\n\n   # Or: server unix:/var/run/redis/redis.sock;\n\n   # a pool with at most 1024 connections\n   keepalive 1024;\n}\n\ngeo $limit {\n    default 1;\n    10.0.0.0/8 0;\n    192.168.0.0/24 0;\n}\n\nmap $limit $limit_key {\n    0 \"\";\n    1 $remote_addr;\n}\n\nrate_limit_status 429;\n\nlocation = /limit {\n    rate_limit $limit_key requests=15 period=1m burst=20;\n    rate_limit_pass redis;\n}\n\nlocation = /limit_b {\n    rate_limit $limit_key requests=20 period=1m burst=25;\n    rate_limit_prefix b;\n    rate_limit_pass redis;\n}\n\nlocation = /quota {\n    rate_limit $limit_key requests=15 period=1m burst=20;\n    rate_limit_quantity 0;\n    rate_limit_pass redis;\n    rate_limit_headers on;\n}\n```\n\n## Installation\n\n*Note: You will need to install the Redis module first, see the install instructions [here](https://github.com/onsigntv/redis-rate-limiter#install).*\n\nYou can install this module manually by recompiling the standard Nginx core as follows:\n\n1. Grab the nginx source code from [nginx.org](https://nginx.org) (this module is tested on version 1.27.3).\n2. Clone this repository into a newly created directory (for e.g. `./rate-limit-nginx-module`)\n3. Build the nginx source with this module:\n```bash\nwget https://nginx.org/download/nginx-1.27.3.tar.gz\ntar -xzvf nginx-1.27.3.tar.gz\ncd nginx-1.27.3/\n\ngit clone https://github.com/weserv/rate-limit-nginx-module rate-limit-nginx-module\n\n# Here we assume you would install you nginx under /opt/nginx/.\n./configure --prefix=/opt/nginx \\\n            --add-module=rate-limit-nginx-module/\n\nmake -j$(nproc)\nmake install\n```\n\n## Test suite\n\nThe following dependencies are required to run the test suite:\n\n* Nginx version \u003e= 1.9.11\n\n* Perl modules:\n    * [Test::Nginx](https://metacpan.org/pod/Test::Nginx::Socket)\n\n* Nginx modules:\n\t* ngx_http_rate_limit_module (i.e., this module)\n\n* Redis modules:\n    * [redis-rate-limiter](https://github.com/onsigntv/redis-rate-limiter)\n\n* Applications:\n\t* redis: listening on the default port, 6379.\n\nTo run the whole test suite in the default testing mode:\n```bash\ncd /path/to/rate-limit-nginx-module\nexport PATH=/path/to/your/nginx/sbin:$PATH\nprove -I/path/to/test-nginx/lib -r t\n```\n\nTo run specific test files:\n```bash\ncd /path/to/rate-limit-nginx-module\nexport PATH=/path/to/your/nginx/sbin:$PATH\nprove -I/path/to/test-nginx/lib t/sanity.t\n```\n\nTo run a specific test block in a particular test file, add the line\n`--- ONLY` to the test block you want to run, and then use the `prove`\nutility to run that `.t` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweserv%2Frate-limit-nginx-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweserv%2Frate-limit-nginx-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweserv%2Frate-limit-nginx-module/lists"}