kong插件rate-limiting怎么设置

这篇文章主要介绍“kong插件rate-limiting怎么设置”,在日常操作中,相信很多人在kong插件rate-limiting怎么设置问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”kong插件rate-limiting怎么设置”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

设置全局插件rate-limiting ,每分钟请求次数是5次 数据存储在本地内存中

curl -i -X POST http://localhost:8001/plugins /--data "name=rate-limiting" /--data "config.minute=5" /--data "config.policy=local"HTTP/1.1 201 CreatedDate: Fri, 31 Jul 2020 08:23:16 GMTContent-Type: application/json; charset=utf-8Connection: keep-aliveAccess-Control-Allow-Origin: *Server: kong/2.1.0Content-Length: 497X-Kong-Admin-Latency: 10{"created_at":1596183796,"id":"5beb7c20-b8a3-4fb1-a0b1-2a6b5ed9af20","tags":null,"enabled":true,"protocols":["grpc","grpcs","http","https"],"name":"rate-limiting","consumer":null,"service":null,"route":null,"config":{"hide_client_headers":false,"minute":5,"policy":"local","month":null,"redis_timeout":2000,"limit_by":"consumer","redis_password":null,"second":null,"day":null,"redis_database":0,"year":null,"hour":null,"redis_host":null,"redis_port":6379,"header_name":null,"fault_tolerant":true}}

连续请求6次

curl -i -X GET http://localhost:8000/mock/requestHTTP/1.1 429 Too Many RequestsDate: Fri, 31 Jul 2020 08:24:37 GMTContent-Type: application/json; charset=utf-8Connection: keep-aliveRetry-After: 23Content-Length: 41X-RateLimit-Remaining-Minute: 0X-RateLimit-Limit-Minute: 5RateLimit-Remaining: 0RateLimit-Limit: 5RateLimit-Reset: 23X-Kong-Response-Latency: 1Server: kong/2.1.0{  "message":"API rate limit exceeded"}

到此,关于“kong插件rate-limiting怎么设置”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/225808.html

(0)
上一篇 2022年1月8日
下一篇 2022年1月8日

相关推荐

发表回复

登录后才能评论