-
Notifications
You must be signed in to change notification settings - Fork 353
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
Configurable ClientIP utility function #1620
Comments
It’s not possible to do it in general. The alb->nlb case is wrong, in case we implicitly switch without creating a new skipper stack and I am more in favor of non new stack creation, because of several reasons. One example is cost, another is east west routing will not work as expected, yet another is additional complexity. |
@szuecs Look from users perspective - they don't really want to (or even can not) know in depth all the details and implications of the setup especially when skipper is provided as infrastructure. What they want is to use "client ip" and proper "client ip" definition depends on the setup. In this ticket I propose to configure proper "client ip" for all modules at once. |
@AlexanderYastrebov users perspective, that's why I proposed the PreProcessor! |
Is your feature request related to a problem? Please describe.
There are several modules where client IP address is required.
Depending on the setup it can be reliably obtained from:
http.Request.RemoteAddr
attributeX-Forwarded-For
header (e.g. when behind a loadbalancer)X-Forwarded-For
headerDifferent modules (predicates, rate limiters, load balancing) use different strategies to obtain client IP address. E.g. there are three predicates
Source
,SourceFromLast
andClientIP
that implement three different ways to obtain client IP.Ratelimiters can obtain IP address from first
X-Forwarded-For
header (viaXForwardedForLookuper
) but not from last, there is also no way to obtain IP address fromhttp.Request.RemoteAddr
directly regardless ofX-Forwarded-For
(similar problem #1614 addresses).ConsistentHash loadbalancer algorithm always uses first
X-Forwarded-For
header.Describe the solution you would like
Define
ClientIP
utility function that uses implementation configured on startup via command flag, something like:and use it everywhere client IP address is meant.
This will ensure the proper implementation is used in all cases and there is no need to repeat algorithm selection in every module that requires client IP.
Describe alternatives you've considered (optional)
Every module supports client IP algorithm selection. When skipper is provided as infrastructure (say ingress) users have to be aware of the differences between algorithms.
Additional context (optional)
ClientIP
an oldRemoteHost
can be repurposedSource
,SourceFromLast
andClientIP
predicates may become aliases and all use the configured algorithm. This ensures routes are safe regardless of predicate used by users.XForwardedForLookuper
may use the configured implementation. Also a newClientIPLookuper
could be introduced.Would you like to work on it?
Yes, let's discuss first
The text was updated successfully, but these errors were encountered: