当前位置:网站首页>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
}
]
}*
*
*
边栏推荐
- Reading notes of top performance version 2 (II) -- Performance observation tool
- 揭开SSL的神秘面纱,了解如何用SSL保护数据
- Introduction notes to machine learning
- 02 MongoDB数据类型、重要概念以及shell常用指令
- Learning about DC-DC step-down chip of sy8120i (12V reduced to 3.3V)
- ambari SSLError: Failed to connect. Please check openssl library versions.
- 从零到一,教你搭建「以文搜图」搜索服务(一)
- 指针链表
- MySQL 主从复制、分离解析
- Arrangement of basic electrical knowledge (I)
猜你喜欢

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

In the era of video explosion, who is supporting the high-speed operation of video ecological network?

Particle theory of light (photoelectric effect / Compton effect)

2021年终总结及2022年展望

《性能之巅第2版》阅读笔记(二)--CPU监测

几个重要的物理概念

数字电路学习笔记(一)

Door level modeling - learning notes

【小程序实战系列】电商平台源码及功能实现

Principle and Simulation of switching power supply buck circuit
随机推荐
测不准原理
简单工厂模式
How the uni app automatically switches the requested address according to the environment
内卷、躺平与中年危机的相关思考
Reading notes of top performance version 2 (II) -- CPU monitoring
利用 telegraf influxdb grafana 搭建服务器监控平台
黑体辐射初探
多项目设计开发·类库项目引入入门
@Several scenarios of transactional failure
MSc 307 (88) (2010 FTPC code) Part 2 smoke and toxicity test
Building log analysis system with elk (II) -- deployment and installation
From zero to one, I will teach you to build a "search by text and map" search service (I)
Learning notes of digital circuit (II)
02 MongoDB数据类型、重要概念以及shell常用指令
【Linux】【Mysql】ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘
02 mongodb data types, important concepts and common shell instructions
03 summary of various additions, updates and deletions of mongodb documents
Reverse a stack with recursive functions and stack operations only
Another option for ERP upgrade, MES system
English语法_形容词/副词3级-比较级_常用短语