DigitalFactory/Admin.NET/Admin.NET.Application/Configuration/Limit.json

121 lines
3.7 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json",
// IP限流配置
"IpRateLimiting": {
// 例如:设置每分钟5次访问限流
// 当False时每个接口都加入计数不管你访问哪个接口只要在一分钟内累计够5次将禁止访问。
// 当True 时当一分钟请求了5次GetData接口则该接口将在时间段内禁止访问但是还可以访问PostData()5次,总得来说是每个接口都有5次在这一分钟互不干扰。
"EnableEndpointRateLimiting": true,
// 如果StackBlockedRequests设置为false拒绝的API调用不会添加到调用次数计数器上。比如如果客户端每秒发出3个请求并且您设置了每秒一个调用的限制
// 则每分钟或每天计数器等其他限制将仅记录第一个调用即成功的API调用。如果您希望被拒绝的API调用计入其他时间的显示分钟小时等则必须设置
"StackBlockedRequests": false,
// 在RealIpHeader使用时你的Kestrel服务器背后是一个反向代理如果你的代理服务器使用不同的页眉然后提取客户端IP X-Real-IP使用此选项来设置它。
"RealIpHeader": "X-Real-IP",
// 将ClientIdHeader被用于提取白名单的客户端ID。如果此标头中存在客户端ID并且与ClientWhitelist中指定的值匹配则不应用速率限制。
"ClientIdHeader": "X-ClientId",
// IP白名单:支持Ipv4和Ipv6
"IpWhitelist": [],
// 端点白名单
"EndpointWhitelist": [],
// 客户端白名单
"ClientWhitelist": [],
"QuotaExceededResponse": {
"Content": "{{\"code\":429,\"type\":\"error\",\"message\":\"访问过于频繁,请稍后重试!\",\"result\":null,\"extras\":null}}",
"ContentType": "application/json",
"StatusCode": 429
},
// 返回状态码
"HttpStatusCode": 429,
// API规则,结尾一定要带*
"GeneralRules": [
// 1秒钟只能调用10次
{
"Endpoint": "*",
"Period": "1s",
"Limit": 10
},
// 1分钟只能调用600次
{
"Endpoint": "*",
"Period": "1m",
"Limit": 600
},
// 1小时只能调用3600
{
"Endpoint": "*",
"Period": "1h",
"Limit": 3600
},
// 1天只能调用86400次
{
"Endpoint": "*",
"Period": "1d",
"Limit": 86400
}
]
},
"IpRateLimitPolicies": {
"IpRules": [
{
"Ip": "XXX.XXX.XXX.XXX",
"Rules": [
{
"Endpoint": "*",
"Period": "1s",
"Limit": 10
},
{
"Endpoint": "*",
"Period": "1m",
"Limit": 600
}
]
}
]
},
// 客户端限流配置
"ClientRateLimiting": {
"EnableEndpointRateLimiting": true,
"ClientIdHeader": "X-ClientId",
"EndpointWhitelist": [],
"ClientWhitelist": [],
"QuotaExceededResponse": {
"Content": "{{\"code\":429,\"type\":\"error\",\"message\":\"访问人数过多,请稍后重试!\",\"result\":null,\"extras\":null}}",
"ContentType": "application/json",
"StatusCode": 429
},
"HttpStatusCode": 429,
"GeneralRules": [
{
"Endpoint": "*",
"Period": "1s",
"Limit": 10
},
{
"Endpoint": "*",
"Period": "1m",
"Limit": 600
}
]
},
"ClientRateLimitPolicies": {
"ClientRules": [
{
"ClientId": "xxx-xxx",
"Rules": [
{
"Endpoint": "*",
"Period": "1s",
"Limit": 10
},
{
"Endpoint": "*",
"Period": "1m",
"Limit": 600
}
]
}
]
}
}