shreemaan-abhishek commented on issue #9328:
URL: https://github.com/apache/apisix/issues/9328#issuecomment-1654965551

   @rukolahasser, if you want to do rate-limiting based on the username. You 
can add the username to the request as a header and then do rate limiting based 
on that header value (by setting the rate-limiting key to the given header 
value) like so:
   
   Then, you can set the `key` for rate limiting based on that variable like so:
   
   ```bash
   curl -i http://127.0.0.1:9180/apisix/admin/routes/1 \
   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uri": "/index.html",
       "plugins": {
           "limit-count": {
               "count": 52,
               "time_window": 60,
               "key": "http_nameofthevarthatsetstheusername" <--- accessing the 
client request header
           }
       },
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "127.0.0.1:1980": 1
           }
       }
   }'
   ```
   
   Accessing custom client request header in nginx using an nginx var: 
https://nginx.org/en/docs/http/ngx_http_core_module.html#var_http_


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to