Kong: Response Rate Limiting Sample

Created on 5 Apr 2016  Â·  2Comments  Â·  Source: Kong/kong

Hi, I´m trying to create a sample with Response Rate Limiting but doest work:

curl -X POST http://localhost:8001/apis/Sandbox/plugins --data "name=response-ratelimiting" --data "config.limits.countries.minute=2" --data "config.header_name=countries"

after two calls throught api still responde!

response
X-RateLimit-Limit-countries-hour →2000
X-RateLimit-Limit-countries-minute →2
X-RateLimit-Remaining-countries-hour →2000
X-RateLimit-Remaining-countries-minute →2
what i need to add on request to put this work?

Can you provide a samlpe?
thanks

Most helpful comment

Add the API

curl -i -X POST --url http://kong.labservers.net:8001/apis --data 'name=loadtest' --data 'upstream_url=http://endpoint.labservers.net/' --data 'request_host=endpoint.labservers.net'

Add the plugin

curl -X POST --url http://kong.labservers.net:8001/apis/loadtest/plugins --data 'name=rate-limiting' --data 'config.minute=10000000' --data 'config.async=true'

Test

curl -I --url http://kong.labservers.net:8000/sample.json --header 'Host: endpoint.labservers.net'

Results

HTTP/1.1 200 OK
Server: nginx/1.0.15
Date: Thu, 07 Apr 2016 16:32:08 GMT
Content-Type: application/json
Connection: keep-alive
Content-Length: 208494
X-RateLimit-Limit-second: 1000000
X-RateLimit-Remaining-second: 999999
Last-Modified: Thu, 25 Feb 2016 18:52:10 GMT
ETag: "56cf4d5a-32e6e"
Accept-Ranges: bytes
X-Kong-Upstream-Latency: 2
X-Kong-Proxy-Latency: 3
Via: kong/0.8.0rc1

I hope this helps. Only thing I changed was the actual servers to be generic.

All 2 comments

Add the API

curl -i -X POST --url http://kong.labservers.net:8001/apis --data 'name=loadtest' --data 'upstream_url=http://endpoint.labservers.net/' --data 'request_host=endpoint.labservers.net'

Add the plugin

curl -X POST --url http://kong.labservers.net:8001/apis/loadtest/plugins --data 'name=rate-limiting' --data 'config.minute=10000000' --data 'config.async=true'

Test

curl -I --url http://kong.labservers.net:8000/sample.json --header 'Host: endpoint.labservers.net'

Results

HTTP/1.1 200 OK
Server: nginx/1.0.15
Date: Thu, 07 Apr 2016 16:32:08 GMT
Content-Type: application/json
Connection: keep-alive
Content-Length: 208494
X-RateLimit-Limit-second: 1000000
X-RateLimit-Remaining-second: 999999
Last-Modified: Thu, 25 Feb 2016 18:52:10 GMT
ETag: "56cf4d5a-32e6e"
Accept-Ranges: bytes
X-Kong-Upstream-Latency: 2
X-Kong-Proxy-Latency: 3
Via: kong/0.8.0rc1

I hope this helps. Only thing I changed was the actual servers to be generic.

Thanks, my bad, i forget to add the response header to control the limits

Was this page helpful?
0 / 5 - 0 ratings