大网数据广告活动
服务器运维问答

Nginx - Can I specify rate in limit_req_zone in requests per hour?

· 52CE 我爱测

While limiting the number of requests from an IP, I am using limit_req_zone $binary_remote_addr zone=one:10m rate=1r/m; I can specify the rate in r/m (requests per minute) or r/s (requests per second). Is there a way to specify t…

问题原文

原帖链接 · Madhav Khakhar · CC BY-SA 3.0

While limiting the number of requests from an IP, I am using

limit_req_zone  $binary_remote_addr zone=one:10m rate=1r/m;

I can specify the rate in r/m (requests per minute) or r/s (requests per second). Is there a way to specify the rate in requests/hour ?

For example, I want the rate to be 75 requests/hour. So it will be 1.25r/m, but r/m has to be an integer. So, even that way it doesn't work.

Please help me out.

已采纳解答

原帖链接 · Tim · CC BY-SA 3.0

According to the documentation you can specify in requests per second or requests per minute, not requests per hour, so no it's not possible.

The rate is specified in requests per second (r/s). If a rate of
less than one request per second is desired, it is specified in
request per minute (r/m). For example, half-request per second
is 30r/m.

I suggest you round up or round down, according to your use case. 1r/s is 60 requests per minute, 2r/s is 120 requests per minute.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。