Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote_address #97

Closed
eguzki opened this issue Oct 4, 2024 · 3 comments · Fixed by #111
Closed

remote_address #97

eguzki opened this issue Oct 4, 2024 · 3 comments · Fixed by #111
Assignees
Labels
enhancement New feature or request size/medium

Comments

@eguzki
Copy link
Contributor

eguzki commented Oct 4, 2024

remote_address is the action name exposed by Envoy filter envoy.filters.http.ratelimit. The description of remote_address

The following descriptor entry is appended to the descriptor and is populated using the trusted address from [x-forwarded-for](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#config-http-conn-man-headers-x-forwarded-for):

("remote_address", "<trusted address from x-forwarded-for>")

This seems pretty fundamental feature to rate limit by IP.

The ask here is to create a WellKnownAttribute ™️ that reproduces the same behavior.

Related info

@eguzki eguzki added enhancement New feature or request size/medium labels Oct 4, 2024
@eguzki eguzki self-assigned this Oct 4, 2024
@eguzki eguzki added this to Kuadrant Oct 4, 2024
@eguzki eguzki moved this to In Progress in Kuadrant Oct 4, 2024
@roivaz
Copy link

roivaz commented Oct 4, 2024

About XFF and rate limiting on an edge gateway using it, caution is required, as the header can be easily forged. See https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#x-forwarded-for for more information on how the header is treated by envoy depending on user's configuration.

Specifically talking about istio, the user needs to specify the number of trusted hops in front of the gateway in order for istio to make the required configurations so the remote address is properly guessed from the header. See https://istio.io/latest/docs/ops/configuration/traffic-management/network-topologies/#configuring-x-forwarded-for-headers. Might be something worth documenting somewhere within kudrant/limitador?

@eguzki
Copy link
Contributor Author

eguzki commented Oct 15, 2024

@roivaz thanks for the heads up.

I have done some tests about how Envoy behaves. I will write details on the PR implementing this feature, but TL;DR is that the implementation in the Kuadrant's Wasm module will delegate the computation of the trusted client address to Envoy and use that for the rate limiting well known attribute remote_address (or whatever it is named in the end). That means that in an environment where there are one or more trusted proxies in front of the gateway where the kuadrant module lives, the xff_num_trusted_hops Envoy's HTTP connection manager attribute will play the expected role. The way xff_num_trusted_hops is being specified depends on the envoy's control plane.

@roivaz
Copy link

roivaz commented Oct 15, 2024

@eguzki for sail operator you can basically use any configuration option that the Istio helm charts expose. The field spec.values.meshConfig.defaultConfig.gatewayTopology.numTrustedProxies in the sail custom resource should do it.
On the other hand, all these options configure numTrustedProxies for all Gateways, but there's a way to configure it on a per-gateway basis, by adding the following annotation:

proxy.istio.io/config: '{"gatewayTopology":{"numTrustedProxies":0}}'

@eguzki eguzki linked a pull request Oct 15, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from In Progress to Done in Kuadrant Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/medium
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants