How can we set the rate limit based on response status code

I have configured the rate limit plugin with limit_by IP in the AKS cluster and it working properly but it consider the preflights request(options) too. So we could not exactly met the rate limit policy in the Custer. Can you please let me know whether we can set the rate limit based on the response status code like 200 etc.

I have followed the below documentation to configure the rate limit in AKS.

You can create two Routes in Kong:

  • r1, with methods attribute not set (default)
  • r2, with methods set to OPTIONS

Apply the rate-limiting plugin on r1. OPTIONS requests won’t match against r1 and hence, rate-limiting won’t be applied to OPTIONS requests.

You can do the same with Ingress resource.

Thanks for your update.
I have created the 2 routes with following method attribute.
r1 method [POST,GET]
r2 method [OPTIONS]
and apply the rate limit plugin to r1 and it working as expected. (Rate-Limit value won’t applied to the OPTIONS request)
After reaching the rate-limit for the r1 route path and it failed with CROS origin error instead of returning rate-limit error message i.e { “message”: “API rate limit exceeded” } with status code 429.
Please let me know if i missed anything else from my side

Not sure I understand. Can you rephrase please?

Thanks for your update.
I have created the 2 routes with following method attribute.
r1 method [POST,GET]
r2 method [OPTIONS]
and apply the rate limit plugin to r1 and it working as expected. (Rate-Limit value won’t applied to the OPTIONS request)
After reaching the rate-limit for the r1 route path and it failed with CROS origin error instead of returning rate-limit error message i.e { “message”: “API rate limit exceeded” } with status code 429.
Please let me know if i missed anything else from my side

That’s odd. I’m not an expert on CORS, but are you sure that you are sending the same request before and after the rate-limit is reached?


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ