How to disable connection closing on error responses generated by HAProxy itself

If HAProxy generates an error response (either by itself or by an HTTP rule), like for example in case of 502 / 503, it also appends the Connection: close header, and terminates the connection (in HTTP/1.1 mode).

However, when HAProxy itself is behind another proxy (like for example a CDN like CloudFlare), closing the connection is counter-productive, as it’s not the CDN’s fault, but instead the clients.

Thus my question is how to disable (if possible) this connection closing behaviour?

(I’m using HAProxy 1.8.21, and by looking at the documentation I didn’t find any solution to this. Using option http-keep-alive in the frontend doesn’t do anything in this situation.)