当前位置:网站首页>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
}
]
}*
*
*
边栏推荐
猜你喜欢

Several important physical concepts

光伏板怎么申请ASTM E108阻燃测试?

Meichuang was selected into the list of "2022 CCIA top 50 Chinese network security competitiveness"

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?

Reading notes of top performance version 2 (II) -- Performance observation tool

数字电路学习笔记(二)

Understanding and learning of parental delegation mechanism

有关函数模板的那些小知识-.-

RT-Thread 双向链表(学习笔记)

从零到一,教你搭建「以文搜图」搜索服务(一)
随机推荐
Sorting from one stack to another
Pychart shares third-party modules among different projects
GenICam GenTL 标准 ver1.5(2)
From zero to one, I will teach you to build a "search by text and map" search service (I)
基于arm5718的Shell脚本参数传递的2种方法
Does the applet image component not display pictures?
单一职责原则
简单工厂模式
Lingge leangoo agile Kanban tool adds the functions of exporting card documents and pasting shared brain map nodes
视频爆炸时代,谁在支撑视频生态网高速运行?
leetcode - 329. 矩阵中的最长递增路径
MSc 307 (88) (2010 FTPC code) Part 2 smoke and toxicity test
English语法_形容词/副词3级 - 比较级
Uncertainty principle
English语法_形容词/副词3级-比较级_常用短语
电学基础知识整理(一)
领歌leangoo敏捷看板工具新增导出卡片文档和粘贴共享脑图节点功能
电学基础知识整理(二)
English grammar_ Adjective / adverb Level 3 - Comparative_ Useful Expressions
PostgreSQL implements batch update, deletion and insertion