My issue:
nginx is setting content-length to 0 multipart http requests at nginx before forwarding request to node.js application. form-boundary value is also getting update to that of the previous request. However, all the other headers remain intact.
How I encountered the problem:
A node.js application that is behind the nginx proxy is unable to read multipart http requests and returns a stream ended unexpectedly error. Upon observing the headers we notice that the Content-Length is set to 0, even though this is not the case in the request submitted from the browser.
Note that we do not encounter this error when the request is submitted directly to the node.js application, bypassing nginx.
Solutions I’ve tried:
Updating and testing following configurations on nginx
- gzip off and proxy_buffering off
- gzip off
- proxy_buffering off and proxy_request_buffering off;
- more_clear_headers Content-Length
- Removing proxy_max_temp_file_size 0
- proxy_set_header Connection “”
- client_max_body_size 200m
Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric):
nginx 1.28.0
What could be the most likely cause for this issue where the Content-Length header is getting modified?