Revolyssup commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1637412066

   @huangyutongs Your feature request is valid but as of now we don't have a 
way to rate limit based on header. We can add the header based rate limiting by 
just generating and setting unique variables for a key-value pair combination 
in the header.
   Although there is a workaround, since APISIX is extensible via plugins, you 
can use serverless plugin to add this logic yourself. 
   You can use `serverless-pre-function` and inside there check if the request 
has the key-value combination in the header. If it does, then you can set a 
custom variable on ngx.var.SOME_VAR and then use this `SOME_VAR` in your 
limit-con plugin configuration as the variable on the basis of which to rate 
limit. 
   For the key-value pair, you want to add rate limiting, you can fix a 
variable. And for all other requests you can generate random value for that 
variable to simulate new user requests. This is a hack and currently there is 
no straightforward way of supporting this feature. 
   
   The logic in the plugin is that the rate limiting is applied uniformly for 
that variable which means if the variable is `remote_addr` then the rate 
limiting will be applied uniformly to all client. 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to