-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
Incorrect handling of Proxy-Connection: close
#57722
Comments
I don't think this is a Node bug (although it is a bit debatable). Sending "proxy-connection" to a server is effectively the client saying "I think you are proxy who will forward this request. This is how I want you to manage the client-to-proxy part of this connection (close vs keep-alive etc)". Sending "Connection" is the modern alternative, intended to work for proxies and servers, and means "Here is how I want you to manage the direct connection between us". I.e. it's slightly more general, but is effectively defining the same thing for the same connection. In all cases, sending both headers with different values is a bad idea - it's similar to just sending two Clients are also not really supposed to send this header in the first place either, since Overall I'm not sure what the best behaviour for Node would be here. It's worth noting that Node doesn't ever actually know whether it's an end-server or an intermediary (there's plenty of Node-based HTTP proxies, and in a microservice world you can easily be both), and it does sound like there's a real world of legacy systems that do use this header, so dropping it might break things. Both behaviours are spec compliant anyway: we can ignore |
Version
v20.13.1
OR
v22.14.0
OR
v23.11.0
Platform
Subsystem
http
What steps will reproduce the bug?
Given the following trivial HTTP server:
You will also need two HTTP requests, it's probably possible to rig up a client to do this but I just used
nc
, so:req1
req2
Then, startup the HTTP server and use the following:
and compare to
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
The expected behavior is for nodejs to keep the connection alive I expect to see:
What do you see instead?
I get a response with a
Connection: close
headerAdditional information
The HTTP RFCs aren't completely clear on this - https://www.rfc-editor.org/rfc/rfc9110.html#name-connection suggests that proxy-connection should be removed (which is what we're now doing as a workaround). https://datatracker.ietf.org/doc/html/rfc9112#appendix-C.2.2 suggests that clients should not be sending it in the first place.
This was causing some issues for us with a nginx frontend - nginx was keeping the connection alive, so whenever a client sent a header with a "proxy-connection" header, the next request on that socket would fail and nginx would respond with a 400.
I do not expect node's HTTP server to be honoring proxy- headers absent some explicit configuration
The text was updated successfully, but these errors were encountered: