如何按IP限制下载文件速度

75 views
Skip to first unread message

li lu

unread,
Jun 10, 2019, 4:24:47 AM6/10/19
to openresty
limit_rate指令 是按连接来限制。我有个需求,是要按IP限制下载速度。假如设置IP的阀值是3M,我有3个下载连接 那么平均每个连接就是3M/3=1M。我在github上找到

Nginx-limit-traffic-rate-module 这个包,基本可以实现功能。可是需要把这个包编译到openresty,我没接触过C开发,不知道怎么在win64平台上把Nginx包编译进openresty,或者openresty本身有什么好的解决方案

Guanglin Lv

unread,
Jun 16, 2019, 10:09:03 PM6/16/19
to openresty
limit_rate支持变量的,你可以写个lua代码,根据不同IP修改变量(ngx.var.limit_rate)值。不过,需要注意,limit_rate是按worker级别限速的。

在 2019年6月10日星期一 UTC+8下午4:24:47,li lu写道:
Reply all
Reply to author
Forward
0 new messages