当前位置:网站首页>AspNetCoreRateLimit 速率限制 接口访问限制 限流控制
AspNetCoreRateLimit 速率限制 接口访问限制 限流控制
2022-06-28 03:41:00 【KingCruel】
AspNetCoreRateLimit 是一种 ASP.NET Core 速率限制解决方案,旨在控制客户端可以根据 IP 地址或客户端 ID 向 Web API 或 MVC 应用程序发出的请求速率。AspNetCoreRateLimit 包包含一个 IpRateLimitMiddleware 和一个 ClientRateLimitMiddleware,对于每个中间件,您可以为不同的场景设置多个限制,例如允许 IP 或客户端在每秒、15 分钟等时间间隔内进行最大调用次数。您可以定义这些限制来解决对 API 发出的所有请求,或者您可以将限制范围限定为每个 API URL 或 HTTP 动词和路径。
github 地址
https://github.com/stefanprodan/AspNetCoreRateLimit
功能
基于客户端 IP 的速率限制
●设置和配置
●定义速率限制规则
●行为
●运行时更新速率限制
基于客户端 ID 的速率限制
●设置和配置
●定义速率限制规则
●行为
●运行时更新速率限制
高级配置
●自定义配额超出响应
●IP / ClientId 解析贡献者
●使用 Redis 作为分布式计数器存储
管理 NuGet 程序包(N)...
AspNetCoreRateLimit
AspNetCoreRateLimit.Redis
1、Startup.cs
*
*
*
*
2、appsettings.json
"IpRateLimiting": {
"EnableEndpointRateLimiting": false,
"StackBlockedRequests": false,
"RealIpHeader": "X-Real-IP",
"ClientIdHeader": "X-ClientId",
"HttpStatusCode": 429,
"IpWhitelist": [ "127.0.0.1", "::1/10", "192.168.0.0/24" ],
"EndpointWhitelist": [ "get:/api/license", "*:/api/status" ],
"ClientWhitelist": [ "dev-id-1", "dev-id-2" ],
"GeneralRules": [
{
"Endpoint": "*",
"Period": "1s",
"Limit": 2
},
{
"Endpoint": "*",
"Period": "15m",
"Limit": 100
},
{
"Endpoint": "*",
"Period": "12h",
"Limit": 1000
},
{
"Endpoint": "*",
"Period": "7d",
"Limit": 10000
}
]
}
*
*
*
边栏推荐
- ambari SSLError: Failed to connect. Please check openssl library versions.
- 2021 year end summary and 2022 outlook
- 歐洲家具EN 597-1 跟EN 597-2兩個阻燃標准一樣嗎?
- Iso8191 test is mentioned in as 3744.1. Are the two tests the same?
- Zipkin service link tracking
- C语言十进制与BCD码的相互转换
- 机器学习入门笔记
- One article tells you what kubernetes is
- English grammar_ Adjective / adverb Level 3 - Comparative
- Market competitiveness of robot programming education
猜你喜欢
数字电路学习笔记(二)
Open the field of maker education and creation
From zero to one, I will teach you to build a "search by text and map" search service (I)
Notes to friendship chain
leetcode - 329. Longest increasing path in matrix
简单工厂模式
基于正点原子stm32的mini板的TFTLCD显示实验
公司领导说,个人代码超10个Bug就开除,是什么体验?
Genicam gentl standard ver1.5 (2)
MySQL master-slave replication, separation and resolution
随机推荐
A summary of my recent situation in June 2022
How to write a software test report? Here comes the third party performance report template
Visualization of loss using tensorboard
有关函数模板的那些小知识-.-
领歌leangoo敏捷看板工具新增导出卡片文档和粘贴共享脑图节点功能
Notes to friendship chain
Introversion, lying flat and midlife crisis
Using elk to build a log analysis system (I) -- component introduction
Open the field of maker education and creation
错排兼排列组合公式
Building log analysis system with elk (II) -- deployment and installation
光的粒子说(光电效应/康普顿效应)
《性能之巅第2版》阅读笔记(二)--性能观察工具
01 MongoDB的概述、应用场景、下载方式、连接方式和发展历史等
MSC 307(88) (2010 FTPC Code)第2部分烟气和毒性测试
美创入选“2022 CCIA中国网络安全竞争力50强”榜单
仅用递归函数和栈操作逆序一个栈
Building log analysis system with elk (III) -- Security Authentication
Arrangement of basic electrical knowledge (II)
抖音实战~取关博主