Membrane API Gateway returns 502 Bad Gateway when the backend's response has invalid HTTP framing or a malformed header block. Membrane cannot tell where the response ends, or cannot parse its headers, so it does not forward the response. The backend is at fault, not the client.
The response contains the status 502 Bad Gateway, the title Bad Gateway, a detail that repeats the message of the HTTP parser, the problem type https://membrane-api.io/problems/gateway and a link to this page. The type gateway means that the problem lies between Membrane and an upstream system, not in the client's request.
The headers of an HTTP message tell the receiver how long the body is. If this information is ambiguous, two systems can disagree about where one message ends and the next begins. This is the basis of request and response smuggling attacks. Following RFC 9112, Membrane rejects such responses instead of guessing.
The response contains several Content-Length values that disagree, either as separate header fields or as a comma-separated list.
A Content-Length value is not a non-negative integer, or it is too large to represent.
A header line has no field name followed by a colon, for example an obsolete folded continuation line that starts with whitespace.
A header field name contains a character that is not allowed, such as a control character. Whitespace between the field name and the colon is removed from responses, not rejected.
warn level.curl -v or a network trace, to see the offending header.Content-Length and well-formed header lines.By default, Membrane runs in development mode and adds details to error responses that help you find the problem, including the link to this page. These details may reveal information about your setup. In production, turn them off:
configuration:
production: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---.
In production mode, the title of this error is replaced by Internal Server Error, and the response only says Internal details are hidden. See server log (key: ...). Search the gateway log for that key to find the full error message.
Configuration reference:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.