nginx - Nginx:如何正确设置速率限制?
问题描述
经过艰苦的谷歌搜索,我找不到如何使用 nginx 和 debian 限制速率的好信息。
我不确定我应该在哪里添加过滤器 nginx.conf 或默认值。我将此添加到默认值,不确定是否正确:
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
server {
server_name Realesta74.net;
location / {
limit_req zone=one burst=5;
}
}
可以吗?以及如何测试它?
解决方案
Nginx rate limiting is implemented identically regardless of Linux distribution (Debian, Ubuntu, etc). Nginx officially provides a good tutorial and explaination:
https://www.nginx.com/blog/rate-limiting-nginx/
Testing can be done with multiple-connection URL tools like Siege or Apache Benchmark Tool, and Siege this example uses 30 simultaneous connections to test rate limiting on a web page. 503 responses would show if rate limiting is configured properly:
$ siege -c 30 -r 1 --no-parser https://www.example.com/
推荐阅读
- tcl - 如何使用 TCL 在 Model-sim 10.5c 的 DO 文件中编写线程应用程序?
- laravel-5 - 相同模型的 Laravel 保护路由
- dryioc - 如何从 DryIoc 中的已解析实例中获取隐式创建的范围?
- google-data-studio - 可以连接 2 个数据集的值以在 Google Data Studio 中创建一个表吗?
- jenkins - 试图将 ssh 命令存储为变量 - “错误的变量名”
- angular - NgModel 值未反映在文本框中
- r - 在 `dplyr::filter_at` 中使用 `tidyselect` 选择特定列
- r - 加快 R for 循环
- node.js - 节点js网络套接字在触发数据事件之前等待5秒
- entity-framework - 具有相交表的 EF CF 子导航不起作用