Nepoxx
Nepoxx

Reputation: 5358

Preserve header capitalization in Haproxy

We switched from a legacy Apache server serving as a load balancer (among other things) to haproxy. Apache would preserve header capitalization from upstream servers while haproxy transforms every header into lowercase. Is there a way to modify this behavior?

(I am aware that headers are supposed to be case-insensitive, unfortunately we have a legacy application that only supports a specific case in a specific header. Also, wouldn't modifying headers result in wasted compute cycles?)

Upvotes: 2

Views: 6538

Answers (3)

Gábor Ligeti
Gábor Ligeti

Reputation: 11

I would think that the OP is experiencing an haproxy bug.

The excuse in that patch and the implication of the setting about how it is the applications fault is, well, a fallacy, to avoid using a stronger term. If you have an client/server solution where your client is talking to your own dedicated server which is putting in headers in a specific casing/capitalization, then accepting them in a different capitalization in the application IS the security risk, not the other way round. While it is true that the RFC says that the headers are case insensitive, it doesn't imply at all that a proxy is free to change it. For that reason (i.e. that a dedicated client talking to its dedicated server should legitimately expect it to retain the casing and should consider a change suspicious) I strongly believe that it should be classified as a bug, not a "feature to support bogus apps"; it is a bogus reasoning for an haproxy bug. Haproxy should (at least by default) retain the casing of the headers.

Upvotes: 0

Andrey
Andrey

Reputation: 11788

Thanks to @mjf answer I found a specific way to fix it without recompiling haproxy.

For 2.0, add no option http-use-htx to your haproxy.cfg, for 2.0 [1].

For 2.1 add a set of option h1-case-adjust-bogus-server + h1-case-adjust, for 2.1 [2].

Upvotes: 5

mjf
mjf

Reputation: 528

Maybe this patch may help to solve your issue.

Upvotes: 3

Related Questions