限制客户端IP地址连接,nginx
我正在学习使用VM,Flask,Nginx和Gunicorn的简单天气Web应用程序部署的基础知识。 有人告诉我,将连接量从相同的IP地址限制为5。意味着 - 我希望每个IP客户端只能打开5个与我的网站的连接。 根据此链接: 用于限制连接数量的手册
我应该在HTTP部分:
limit_conn_zone $binary_remote_addr zone=limitconnbyaddr:20m;
然后将此行添加到我的位置块中:
limit_conn limitconnbyaddr 5;
当然,然后测试Nginx,重新启动服务并检查自己。 我的问题是:我该如何检查自己? 我无法找到一种测试我的行动是否好的方法。 (顺便说一句,如果我错了 - 我想对正确的解决方法有很好的解释,如果有人可以) 该网站是使用Python制作的(如上所述)
i'm in the middle of learning the basics of deployment of a simple weather web app using VM, flask, Nginx and gunicorn.
i've been told to limit the amount of connections from the same ip address to 5. meaning - i would like that each ip client could open only 5 connections to my site.
according to this link:
Manual for limiting number of connections
i'm supposed to add this line in the http part:
limit_conn_zone $binary_remote_addr zone=limitconnbyaddr:20m;
then add this line to my location block:
limit_conn limitconnbyaddr 5;
and afterwards, of course, test nginx, restart the service and check myself.
my question is: how can i check myself?
i can't figure out a way to test if my actions were good or not.
(BTW, if i'm wrong - i'd like to have a good explanation to the correct way to solve it, if anyone can)
the website is made using python (as flask mentioned above)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试速率限制方案的快速工具是
Siege
。假设您使用的是Debian-base发行版,请使用:用法:
示例输出(失败的请求将以红色显示):
sidenote:如果详细格式(
-v -v
)仍然显示您的json输出,编辑围攻配置文件(位于〜/.siege/siege.conf
),然后将json_output
指令设置为false
;这应该解决问题。A quick tool to test rate limit scenarios is
siege
. Assuming you're using Debian-base distributions, install it using:Usage:
Sample output (the failed requests will appear in red):
Sidenote: if the verbose format (
-v
) still shows you a JSON output, edit the siege configuration file (located at~/.siege/siege.conf
) and set thejson_output
directive tofalse
; this should solve the issue.