{"id":13425033,"url":"https://github.com/xuqingfeng/caddy-rate-limit","last_synced_at":"2026-02-09T21:24:32.972Z","repository":{"id":37580202,"uuid":"62641907","full_name":"xuqingfeng/caddy-rate-limit","owner":"xuqingfeng","description":"A rate limit plugin for caddy","archived":false,"fork":false,"pushed_at":"2021-04-12T04:28:13.000Z","size":3755,"stargazers_count":66,"open_issues_count":2,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-17T12:07:42.708Z","etag":null,"topics":["caddy","rate-limit"],"latest_commit_sha":null,"homepage":"https://caddyserver.com/docs/http.ratelimit","language":"Go","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/xuqingfeng.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}},"created_at":"2016-07-05T14:08:30.000Z","updated_at":"2024-09-01T20:26:05.000Z","dependencies_parsed_at":"2022-08-29T18:20:52.174Z","dependency_job_id":null,"html_url":"https://github.com/xuqingfeng/caddy-rate-limit","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuqingfeng%2Fcaddy-rate-limit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuqingfeng%2Fcaddy-rate-limit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuqingfeng%2Fcaddy-rate-limit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuqingfeng%2Fcaddy-rate-limit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuqingfeng","download_url":"https://codeload.github.com/xuqingfeng/caddy-rate-limit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243781772,"owners_count":20347145,"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":["caddy","rate-limit"],"created_at":"2024-07-31T00:01:02.809Z","updated_at":"2026-02-09T21:24:27.906Z","avatar_url":"https://github.com/xuqingfeng.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"## caddy-rate-limit\n\u003ea `rate limit` plugin for [caddy](https://caddyserver.com/)\n\n**Only support Caddy v1, try on https://github.com/mholt/caddy-ratelimit if you are using v2**\n\n[![Travis CI](https://img.shields.io/travis/xuqingfeng/caddy-rate-limit/master.svg?style=flat-square\u0026cacheSeconds=3600)](https://travis-ci.org/xuqingfeng/caddy-rate-limit)\n[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/xuqingfeng/caddy-rate-limit?tab=doc)\n\n### Syntax\n\n**Excessive requests will be terminated with an error 429 (Too Many Requests)! And `X-RateLimit-RetryAfter` header will be returned.**\n\nFor single resource:\n\n```\nratelimit methods path rate burst unit\n```\n\n- `methods` are the request methods it will match (comma separately)\n\n- `path` is the file or directory to apply `rate limit`\n\n- `rate` is the limited request in every time unit (r/s, r/m, r/h, r/d, r/w) (e.g. 1)\n\n- `burst` is the maximum burst size client can exceed; burst \u003e= rate (e.g. 2)\n\n- `unit` is the time interval (currently support: `second`, `minute`, `hour`, `day`, `week`)\n\nFor multiple resources:\n\n```\nratelimit methods rate burst unit {\n    whitelist CIDR,CIDR\n    limit_by_header xxx\n    status xxx,xxx\n    resources\n}\n```\n\n- `whitelist` is the keyword for whitelist your trusted ips (comma separately). [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) is the IP range you don't want to perform `rate limit`. `whitelist` is a general rule, it won't target for specific resource.\n- `limit_by_header` is the keyword for matching the [request header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields). Like `whitelist`, it's also a general rule.\n**Note:** normally you shouldn't apply this rule unless the default `limit by ip` is not what you want and you want to `limit by request header`(e.g. `Authorization`).\n- `status` is the keyword for matching the [response status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) (comma separately).\nIf this rule is triggered, all subsequent requests from that client will be blocked regardless of which status code is returned or which resource is requested.\n**Note:** this won't block resources not defined in `ratelimit`'s config.\n- `resources` is a list of files/directories to apply `rate limit`, one per line\n\n**Note:** If you don't want to apply `rate limit` on some special resources, add `^` in front of the path.\n\n\n### Examples\n\nLimit clients to 2 requests per second (bursts of 3) to any methods and any resources under /r:\n\n```\nratelimit * /r 2 3 second\n```\n\nDon't perform `rate limit` if requests come from **1.2.3.4** or **192.168.1.0/30(192.168.1.0 ~ 192.168.1.3)**, for the listed paths, limit clients to 2 requests per minute (bursts of 2) if the request method is **GET** or **POST** and always ignore `/dist/app.js`:\n\n```\nratelimit get,post 2 2 minute {\n    whitelist 1.2.3.4/32,192.168.1.0/30\n    status *\n    /foo.html\n    /api\n    ^/dist/app.js\n}\n```\n\n### Download\n\n`curl https://getcaddy.com | bash -s personal http.ratelimit`\n\n### Docker\n\n```bash\ndocker run -d -p 2016:2016 -v `pwd`/Caddyfile:/Caddyfile -v `pwd`/test_site:/test_site --name ratelimit xuqingfeng/caddy-rate-limit\n```\n\n---\n\n**Inspired by**\n\n[http://nginx.org/en/docs/http/ngx_http_limit_req_module.html](http://nginx.org/en/docs/http/ngx_http_limit_req_module.html)\n\n[https://github.com/didip/tollbooth](https://github.com/didip/tollbooth)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuqingfeng%2Fcaddy-rate-limit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuqingfeng%2Fcaddy-rate-limit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuqingfeng%2Fcaddy-rate-limit/lists"}