{"id":17982424,"url":"https://github.com/nekocode/resty-limit-docker","last_synced_at":"2025-03-25T19:31:07.500Z","repository":{"id":98385846,"uuid":"249388245","full_name":"nekocode/resty-limit-docker","owner":"nekocode","description":"An openresty/nginx based api gateway that can limit max count of connected IPs and traffic speed of network.","archived":false,"fork":false,"pushed_at":"2020-03-23T16:03:08.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T17:23:13.428Z","etag":null,"topics":["docker","network"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/nekocode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-03-23T09:32:52.000Z","updated_at":"2023-09-08T18:04:55.000Z","dependencies_parsed_at":"2023-04-26T08:35:14.730Z","dependency_job_id":null,"html_url":"https://github.com/nekocode/resty-limit-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekocode%2Fresty-limit-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekocode%2Fresty-limit-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekocode%2Fresty-limit-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekocode%2Fresty-limit-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nekocode","download_url":"https://codeload.github.com/nekocode/resty-limit-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245530115,"owners_count":20630497,"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":["docker","network"],"created_at":"2024-10-29T18:14:12.078Z","updated_at":"2025-03-25T19:31:07.494Z","avatar_url":"https://github.com/nekocode.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"该项目中的大部分代码已经经过生产环境的检验，目前主要用于实现「针对用户个体的服务质量限制」，多用于收费服务场景，具体：\n\n* 限制用户能够同时进行连接的 IP 数量（借助 OpenResty 实现，详情可看 [ip-limit.lua](nginx/ip-limit.lua) ）\n* 限制用户的上/下载速度（借助 Linux tc 工具实现，详情可看 [rate-limit.sh](rate-limit.sh) ）\n\n### 配置\n\n以在容器内执行 `./configure.sh -i 5 -u 1000 -d 2000` 为例：\n\n* `-i 5` 表示限制能够同时连接的最大 IP 数量为 5\n* `-u 1000` 表示限制最大上传速度为 1000 kbit/s（等于 1 Mbit/s）\n* `-d 2000` 表示限制最大下载速度为 2000 kbit/s（等于 2 Mbit/s）\n\n以上三个参数均可分别或同时不传，表示无限制。每次执行 `./configure.sh` 会进行对应配置的无停机优雅更新，不会影响现有连接。\n\n### 持久化\n\n将容器的 `/conf` 目录挂载到本地可以实现配置持久化，下次启动/重启容器时会恢复已持久化的配置。\n\n### 注意\n\n限速功能需要创建 Linux 的虚拟设备来进行流量处理，所以需要：\n\n1. 在容器所在主机执行一遍 `modprobe ifb numifbs=1` 命令\n2. 启动容器（Docker Run）时需带上 `--cap-add=NET_ADMIN -v /lib/modules:/lib/modules:ro` 参数\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnekocode%2Fresty-limit-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnekocode%2Fresty-limit-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnekocode%2Fresty-limit-docker/lists"}