-
Notifications
You must be signed in to change notification settings - Fork 595
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
extractClientIp directive ignores X-Forwarded-For header if it includes port #3790
Comments
Looking at the parser code at
|
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For doesn't mention allowing a port, but the standardized It might make sense to support a port, but on the other hand, perhaps it's better to move to the standardized |
We detected the issue when attempting to run our server in Azure environment - it appears that Azure GW by default sends the X-Forwarded-For with the port, rendering |
That indeed matches what I read at https://docs.microsoft.com/en-us/azure/application-gateway/how-application-gateway-works - would be good to support this, would you be interested in preparing a PR? |
@raboof Sure, will try to get it done in the next couple of days. |
There's a previous discussion in #2191 |
I am also impacted by this. |
Also mentioning the IPv6 address with port is likely to have this problem as well In my case over 24 hours this caused about 44 billion warning errors to be logged |
It seems that when X-Forwarded-For has a port, the system fails to parse it as a
X-Forwarded-For
header, and instead parses it as aRawHeader
. This causes the implementation of the extractClientIp directive to not take it into account.When looking at the parsing itself, I see the following error :
ErrorInfo(Invalid input ':', expected listSep or 'EOI' (line 1, column 14), (details omitted), )
To reproduce use a route with
extractClientIp
directive, send an http request withX-Forwarded-For: 10.0.0.1:99999
, expected -extractClientIp
provides10.0.0.1
, actual -extractClientIp
provides the value of the remote address.The text was updated successfully, but these errors were encountered: