您好,登錄后才能下訂單哦!
這篇文章主要介紹“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怎么設置”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。