You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "huangyutongs (via GitHub)" <gi...@apache.org> on 2023/07/13 08:05:21 UTC
[GitHub] [apisix] huangyutongs opened a new issue, #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
huangyutongs opened a new issue, #9830:
URL: https://github.com/apache/apisix/issues/9830
### Description
The current current limit can only be based on the source ip, and there are few coverage scenarios.
If current limiting can be implemented based on specific key values, it will have more scalability.
such as Alibaba Cloud's higress
https://higress.io/zh-cn/docs/plugins/key-rate-limit
--
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-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] qwzhou89 commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "qwzhou89 (via GitHub)" <gi...@apache.org>.
qwzhou89 commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1635375915
> I want to do limit-req for the request header `x-userid: test`, how to do it,
I think you can reference it with $http_x_userid
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] huangyutongs commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "huangyutongs (via GitHub)" <gi...@apache.org>.
huangyutongs commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1637303788
> @huangyutongs, please share your error logs.
Hi, thank you for your attention. In my example above, the ```limit-req``` plug-in function I understand is to limit the restricted traffic with ```x-userid``` in the specified request header, and the unrestricted traffic without ```x-userid``` in the request header , in my demonstration, the request without ```x-userid``` in the request header encountered a current limit, did I understand it wrong?
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Sn0rt commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1643311974
can we close this issue now ?
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers [apisix]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
URL: https://github.com/apache/apisix/issues/9830
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shreemaan-abhishek commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1635636277
@huangyutongs, please share your error logs.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Revolyssup commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1643542872
> can we close this issue now ?
We can keep this issue open for track. Later we can come back to implement this feature. @Sn0rt
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] huangyutongs commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "huangyutongs (via GitHub)" <gi...@apache.org>.
huangyutongs commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1637541164
> @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.
Thanks for your reply, I will try
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers [apisix]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-2247461483
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Revolyssup commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1633935640
@huangyutongs You can use limit-req plugin for rate limiting requests and use the variable field to specify the key. You can add a header as a key using a variable like `$http_name_of_the_header`
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] huangyutongs commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "huangyutongs (via GitHub)" <gi...@apache.org>.
huangyutongs commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1637540195
> could not resolve vars in
> apisixui.baidu.cn
Hi, I made a confidential modification to the domain name in the example, and I can see in the request that it is the current limit triggered by limit-req
```
47#47: *12036552 [lua] plugin.lua:938: run_plugin(): limit-req exits with http status code 500, client: 192.168.110.186, server: _, request: "HEAD / HTTP/1.1", host : "apisixui.baidu.cn"
```
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers [apisix]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-2217224739
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Revolyssup commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] huangyutongs commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "huangyutongs (via GitHub)" <gi...@apache.org>.
huangyutongs commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1634045726
> @huangyutongs You can use limit-req plugin for rate limiting requests and use the variable field to specify the key. You can add a header as a key using a variable like `$http_name_of_the_header` https://apisix.apache.org/docs/apisix/plugins/limit-req/#description
I want to do limit-req for the request header x-userid: test, how to do it,
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] huangyutongs commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "huangyutongs (via GitHub)" <gi...@apache.org>.
huangyutongs commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1635464561
> > I want to do limit-req for the request header `x-userid: test`, how to do it,
>
> I think you can reference it with $http_x_userid
It seems that the content of the request header cannot be obtained
Here is my configuration
```
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: apisix-dashbord-route
spec:
http:
- backends:
- serviceName: apisix-dashboard
servicePort: 80
match:
hosts:
- apisixui.baidu.cn
paths:
- /*
name: apisix-dashbord-route
plugins:
- config:
burst: 0
key: $http_x_userid
key_type: var_combination
rate: 1
rejected_code: 500
rejected_msg: Requests are too frequent, please try again later.
enable: true
name: limit-req
```
Quickly make two requests
```
curl -I 192.168.110.186 -H "host: apisixui.baidu.cn"
HTTP/1.1 500 Internal Server Error
```
There is no x-userid: test in my request header, but it is limited
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Revolyssup commented on issue #9830: feat: As a user, I want to implement current limiting based on a specific key value in the request header. The source of the key value can be URL parameters, HTTP request headers
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #9830:
URL: https://github.com/apache/apisix/issues/9830#issuecomment-1637397758
@huangyutongs Can you confirm if you have an error in your error log, something like `could not resolve vars in ....` ?
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org