HAProxy community

How to retain Connection: keep-alive header in HAProxy 1.5

#1

Hi all,

I have an application is sending a HTTP request to a machine behind a HAProxy vip but the response HAProxy is sending back appears to be missing some headers.
What the sending application is expecting is to see in the response is the “Connection: keep-alive” header, but via the HAProxy, this header is stripped out in the response.

I’ve been trying to write something that will add the header back in to the response if the back-end (receiving) server responds with a “Connection: keep-alive” header but it’s not working:

acl foo hdr(Connection) -m found
rspadd Connection:\ keep-alive if foo

Any ideas on how I can get this working?

Also, I cannot upgrade HAProxy at the moment as it’s actually in-built into an NSX edge…

Thanks!
Leon

#2

Connection: keep-alive is implied in HTTP/1.1. There is no need to set it.

#3

Hi Lukas,

Thanks for the reply, yes I should have mentioned that even though it’s implied in HTTP/1.1 this application needs to see this specific header…
Any help on the acl that would retain it would be appreciated!

Thanks,
Leon

#4

If it has a broken keep-alive implementation you can disable keep-alive on the backend by setting option httpclose.

I’m not sure it’s wise to overwrite connection headers like this. It will interfere with normal operation and cause additional issues (what if haproxy already emits a Connection: close header because it wants to close the connection)?