当前位置:网站首页>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
}
]
}*
*
*
边栏推荐
- 错排兼排列组合公式
- 多项目开发入门,基础设计 类库项目使用
- The operating mechanism of spectrogram in audio Science
- 由两个栈组成的队列
- Learning notes of digital circuit (II)
- Several important physical concepts
- From zero to one, I will teach you to build a "search by text and map" search service (I)
- @Transactional失效的几种场景
- GenICam GenTL 标准 ver1.5(2)
- Introduction notes to machine learning
猜你喜欢
随机推荐
Two methods of shell script parameter passing based on arm5718
Using elk to build a log analysis system (I) -- component introduction
How the uni app automatically switches the requested address according to the environment
多项目设计开发·类库项目引入入门
In the era of video explosion, who is supporting the high-speed operation of video ecological network?
From zero to one, I will teach you to build a "search by text and map" search service (I)
ambari SSLError: Failed to connect. Please check openssl library versions.
What are the password requirements for waiting insurance 2.0? What are the legal bases?
利用ELK 搭建日志分析系统(三)—— 安全认证
领歌leangoo敏捷看板工具新增导出卡片文档和粘贴共享脑图节点功能
Principle and Simulation of switching power supply buck circuit
Lingge leangoo agile Kanban tool adds the functions of exporting card documents and pasting shared brain map nodes
[MySQL] multi table connection query
软件测试报告怎么编写?第三方性能报告范文模板来了
用一个栈实现另一个栈的排序
简单工厂模式
《性能之巅第2版》阅读笔记(二)--性能观察工具
Iso8191 test is mentioned in as 3744.1. Are the two tests the same?
电学基础知识整理(一)
The operating mechanism of spectrogram in audio Science









