当前位置:网站首页>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.Redis1、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
}
]
}*
*
*
边栏推荐
- 揭开SSL的神秘面纱,了解如何用SSL保护数据
- Problems with cat and dog queues
- applicationContext. Getbeansoftype obtains the execution methods of all implementation classes under an interface or obtains the operation application scenarios such as implementation class objects. L
- 【Linux】【Mysql】ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘
- 05 MongoDB对列的各种操作总结
- 基于arm5718的Shell脚本参数传递的2种方法
- Another option for ERP upgrade, MES system
- Does the applet image component not display pictures?
- Iso8191 test is mentioned in as 3744.1. Are the two tests the same?
- C语言十进制与BCD码的相互转换
猜你喜欢

02 MongoDB数据类型、重要概念以及shell常用指令

几个重要的物理概念

From zero to one, I will teach you to build a "search by text and map" search service (I)

The operating mechanism of spectrogram in audio Science

How to learn a programming language systematically| Dark horse programmer

Genicam gentl standard ver1.5 (2)

English grammar_ Adjective / adverb Level 3 - Comparative_ Useful Expressions

La norme européenne en 597 - 1 pour les meubles est - elle la même que les deux normes en 597 - 2 pour les ignifuges?

第一个.net core MVC项目

Market competitiveness of robot programming education
随机推荐
Adder - Notes
光的粒子说(光电效应/康普顿效应)
MSC 307(88) (2010 FTPC Code) Part 5低播焰测试
Sorting from one stack to another
窗帘做EN 1101易燃性测试过程是怎么样的?
leetcode:494. All methods of adding and subtracting operators to the array to get the specified value
01 MongoDB的概述、应用场景、下载方式、连接方式和发展历史等
GO语言-select语句
Staggered and permutation combination formula
03 summary of various additions, updates and deletions of mongodb documents
Arrangement of basic electrical knowledge (I)
Zipkin service link tracking
A preliminary study of blackbody radiation
从零到一,教你搭建「以文搜图」搜索服务(一)
AS 3744.1标准中提及ISO8191测试,两者测试一样吗?
《性能之巅第2版》阅读笔记(二)--性能观察工具
第一章 Bash 入门
English grammar_ Adjective / adverb Level 3 - Comparative_ Useful Expressions
01 overview, application scenarios, Download methods, connection methods and development history of mongodb
Genicam gentl standard ver1.5 (2)