Limit.json 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. {
  2. "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json",
  3. // IP限流配置
  4. "IpRateLimiting": {
  5. // 例如:设置每分钟5次访问限流
  6. // 当False时:每个接口都加入计数,不管你访问哪个接口,只要在一分钟内累计够5次,将禁止访问。
  7. // 当True 时:当一分钟请求了5次GetData接口,则该接口将在时间段内禁止访问,但是还可以访问PostData()5次,总得来说是每个接口都有5次在这一分钟,互不干扰。
  8. "EnableEndpointRateLimiting": true,
  9. // 如果StackBlockedRequests设置为false,拒绝的API调用不会添加到调用次数计数器上。比如:如果客户端每秒发出3个请求并且您设置了每秒一个调用的限制,
  10. // 则每分钟或每天计数器等其他限制将仅记录第一个调用,即成功的API调用。如果您希望被拒绝的API调用计入其他时间的显示(分钟,小时等),则必须设置
  11. "StackBlockedRequests": false,
  12. // 在RealIpHeader使用时,你的Kestrel服务器背后是一个反向代理,如果你的代理服务器使用不同的页眉然后提取客户端IP X-Real-IP使用此选项来设置它。
  13. "RealIpHeader": "X-Real-IP",
  14. // 将ClientIdHeader被用于提取白名单的客户端ID。如果此标头中存在客户端ID并且与ClientWhitelist中指定的值匹配,则不应用速率限制。
  15. "ClientIdHeader": "X-ClientId",
  16. // IP白名单:支持Ipv4和Ipv6
  17. "IpWhitelist": [],
  18. // 端点白名单
  19. "EndpointWhitelist": [],
  20. // 客户端白名单
  21. "ClientWhitelist": [],
  22. "QuotaExceededResponse": {
  23. "Content": "{{\"code\":429,\"type\":\"error\",\"message\":\"访问过于频繁,请稍后重试!禁止违法行为否则110 👮\",\"result\":null,\"extras\":null}}",
  24. "ContentType": "application/json",
  25. "StatusCode": 429
  26. },
  27. // 返回状态码
  28. "HttpStatusCode": 429,
  29. // API规则,结尾一定要带*
  30. "GeneralRules": [
  31. // 1秒钟只能调用1000次
  32. {
  33. "Endpoint": "*",
  34. "Period": "1s",
  35. "Limit": 1000
  36. },
  37. // 1分钟只能调用60000次
  38. {
  39. "Endpoint": "*",
  40. "Period": "1m",
  41. "Limit": 60000
  42. }
  43. //// 1小时只能调用3600000次
  44. //{
  45. // "Endpoint": "*",
  46. // "Period": "1h",
  47. // "Limit": 3600000
  48. //},
  49. //// 1天只能调用86400000次
  50. //{
  51. // "Endpoint": "*",
  52. // "Period": "1d",
  53. // "Limit": 86400000
  54. //}
  55. ]
  56. },
  57. // IP 黑名单
  58. "IpRateLimitPolicies": {
  59. "IpRules": [
  60. {
  61. "Ip": "0.0.0.0", // IP可用:"::1/10"
  62. "Rules": [
  63. {
  64. "Endpoint": "*",
  65. "Period": "1s",
  66. "Limit": 0 // 设置为0就是1次都不能请求,完全屏蔽
  67. }
  68. ]
  69. }
  70. ]
  71. },
  72. // 客户端限流配置
  73. "ClientRateLimiting": {
  74. "EnableEndpointRateLimiting": true,
  75. "ClientIdHeader": "X-ClientId",
  76. "EndpointWhitelist": [],
  77. "ClientWhitelist": [],
  78. "QuotaExceededResponse": {
  79. "Content": "{{\"code\":429,\"type\":\"error\",\"message\":\"访问人数过多,请稍后重试!\",\"result\":null,\"extras\":null}}",
  80. "ContentType": "application/json",
  81. "StatusCode": 429
  82. },
  83. "HttpStatusCode": 429,
  84. "GeneralRules": [
  85. {
  86. "Endpoint": "*",
  87. "Period": "1s",
  88. "Limit": 2000
  89. }
  90. ]
  91. },
  92. "ClientRateLimitPolicies": {
  93. "ClientRules": [
  94. {
  95. "ClientId": "",
  96. "Rules": [
  97. {
  98. "Endpoint": "*",
  99. "Period": "1s",
  100. "Limit": 2000
  101. }
  102. ]
  103. }
  104. ]
  105. }
  106. }