Limit.json 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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\":\"访问过于频繁,请稍后重试!\",\"result\":null,\"extras\":null}}",
  24. "ContentType": "application/json",
  25. "StatusCode": 429
  26. },
  27. // 返回状态码
  28. "HttpStatusCode": 429,
  29. // API规则,结尾一定要带*
  30. "GeneralRules": [
  31. // 1秒钟只能调用1次
  32. {
  33. "Endpoint": "*",
  34. "Period": "1s",
  35. "Limit": 10
  36. },
  37. // 1分钟只能调用100次
  38. {
  39. "Endpoint": "*",
  40. "Period": "1m",
  41. "Limit": 1000
  42. },
  43. // 1小时只能调用1000
  44. {
  45. "Endpoint": "*",
  46. "Period": "1h",
  47. "Limit": 10000
  48. },
  49. // 1天只能调用10000次
  50. {
  51. "Endpoint": "*",
  52. "Period": "1d",
  53. "Limit": 1000000
  54. }
  55. ]
  56. },
  57. "IpRateLimitPolicies": {
  58. "IpRules": [
  59. {
  60. "Ip": "XXX.XXX.XXX.XXX",
  61. "Rules": [
  62. {
  63. "Endpoint": "*",
  64. "Period": "1s",
  65. "Limit": 10
  66. },
  67. {
  68. "Endpoint": "*",
  69. "Period": "1m",
  70. "Limit": 1000
  71. }
  72. ]
  73. }
  74. ]
  75. },
  76. // 客户端限流配置
  77. "ClientRateLimiting": {
  78. "EnableEndpointRateLimiting": true,
  79. "ClientIdHeader": "X-ClientId",
  80. "EndpointWhitelist": [],
  81. "ClientWhitelist": [],
  82. "QuotaExceededResponse": {
  83. "Content": "{{\"code\":429,\"type\":\"error\",\"message\":\"访问人数过多,请稍后重试!\",\"result\":null,\"extras\":null}}",
  84. "ContentType": "application/json",
  85. "StatusCode": 429
  86. },
  87. "HttpStatusCode": 429,
  88. "GeneralRules": [
  89. {
  90. "Endpoint": "*",
  91. "Period": "1s",
  92. "Limit": 10
  93. },
  94. {
  95. "Endpoint": "*",
  96. "Period": "1m",
  97. "Limit": 1000
  98. }
  99. ]
  100. },
  101. "ClientRateLimitPolicies": {
  102. "ClientRules": [
  103. {
  104. "ClientId": "xxx-xxx",
  105. "Rules": [
  106. {
  107. "Endpoint": "*",
  108. "Period": "1s",
  109. "Limit": 10
  110. },
  111. {
  112. "Endpoint": "*",
  113. "Period": "1m",
  114. "Limit": 1000
  115. }
  116. ]
  117. }
  118. ]
  119. }
  120. }