Repository navigation
in_http: reset the client address for each request - #5650
Open
Raed2180416 wants to merge 1 commit into
Open
Raed2180416 wants to merge 1 commit into
Raed2180416 wants to merge 1 commit into
Conversation
Handler#on_headers_complete wrote the X-Forwarded-For address into @remote_addr, which holds the address of the connection, so a later request on the same keepalive connection that did not send the header was attributed to the client of the earlier one. Signed-off-by: Raed <Raed2180416@users.noreply.github.com>
Raed2180416
force-pushed
the
in-http-remote-addr-per-request
branch
from
November 18, 2026 09:06
72c2152 to
792051e
Compare
Watson1978
approved these changes
Nov 18, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix. I reproduced #5649 on master, and the new test fails there and passes with this change.
I also tried TLS, pipelined requests, HTTP/1.0 keep-alive, and Expect: 100-continue. A request without X-Forwarded-For now gets the connection address, and a request with the header still uses the header value. When a later request failed authentication, the warning logged the connection address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Fixes #5649
What this PR does / why we need it:
in_httpreadX-Forwarded-Forinto@remote_addr, the same variable that holds the address of the connection (lib/fluent/plugin/in_http.rb:470). Once a request sent the header, a later request on that keepalive connection without the header reused the most recent forwarded address, andadd_remote_addrrecorded that address.on_headers_completealready resets@env,@content_type,@content_encodingand@authorizationat its start, so the connection address is restored there too.io.remote_addris resolved once per connection, so this adds no lookup. Nothing else changes: a request withX-Forwarded-Forstill overrides the address, and the authentication warning keeps logging whichever address applies to the request.Verified:
bundle exec ruby -Ilib -Itest test/plugin/test_in_http.rb -n /remote_addr_is_not_carried/fails on master with<"127.0.0.1">(UTF-8) expected but was <"192.0.2.1">(ASCII-8BIT)and passes with the change; the whole file passes 66 tests, 238 assertions, 0 failures.rubocop lib/fluent/plugin/in_http.rb test/plugin/test_in_http.rbreports no offenses.Docs Changes:
N/A
Release Note:
in_http: keep the client address per request on a keepalive connection