HTX (http-use-htx) and represention of HTTP headers

Hello,

I’ve got a problem with upgrade HAproxy in my envinronment.

After upgrade from HAproxy v.1.9.x to v.2.4.x, I noticed that HTTP response was changed:

HTTP response from new version HAproxy:


> Content-Length: 17730

>

* upload completely sent off: 17730 out of 17730 bytes

* Mark bundle as not supporting multiuse

< HTTP/1.1 201

HTTP/1.1 201

< location: http://HOST:PORT/SOME/URI

location: http://HOST:PORT/SOME/URI

< content-length: 0

content-length: 0

< date: Tue, 08 Mar 2022 12:10:58 GMT

date: Tue, 08 Mar 2022 12:10:58 GMT<

* Connection #0 to host HOST left intact

HTTP response from old version HAproxy:


> Content-Length: 17730

>

* upload completely sent off: 17730 out of 17730 bytes

* Mark bundle as not supporting multiuse

< HTTP/1.1 201

HTTP/1.1 201

< Location: http://HOST:PORT/SOME/URI

Location: http://HOST:PORT/SOME/URI

< Content-Length: 0

Content-Length: 0

< Date: Tue, 08 Mar 2022 12:11:54 GMT

Date: Tue, 08 Mar 2022 12:11:54 GMT<

* Connection #0 to host HOST left intact

Like you see headers from new version of HAproxy are writter in lower-case and some apps (parsers) in my envinroment are case-sensitive.

To resolve this issue I was trying to add no option http-use-htx to my config but this doesn’t work for HAproxy v.2.x Since the version 2.0-dev3, the HTX is the default mode


[WARNING] (23) : parsing [/opt/haproxy/config/haproxy.cfg:16]: option 'http-use-htx' is deprecated and ignored. The HTX mode is now the only supported mode.

So I was able to rewrite specific headers using h1-case-adjust:

global
  h1-case-adjust content-length Content-Length
  h1-case-adjust location Location
  h1-case-adjust date Date

frontend proxy
  option h1-case-adjust-bogus-client

But this solution it’s not enough for me because I don’t know every header that is used in my envinroment and I don’t want to rewirte every problematic HTTP header in HAproxy config file.

Could you tell me is there any other solution that will make HTTP headers in old (traditional) HTTP representation?

Best regards,

emilwojcik93

In HTTP2 all headers are lowercase/binary, this information is gone.

And haproxy cannot possibly know if x-private-header should be X-PRIVATE-Header or X-pRiVaTe-hEader .

The long term solution to this is to make servers and clients HTTP compliant.

As a workaround you can define a mapping using h1-case-adjust or h1-case-adjust--file global options. Then you can set h1-case-adjust-bogus-client option in your frontend sections and h1-case-adjust-bogus-server option in your backend sections

But I agree with Lukas. The best is to update your apps to be HTTP compliant.

@capflam he already does that, but he doesn’t want to predict all the header names.

But its either that or fixing the real problem.

With HTX mode, everything is HTTP version agnostic. This requires HTTP compliant user-agents:

Just as in HTTP/1.x, header field names are strings of ASCII
characters that are compared in a case-insensitive fashion.  However,
header field names MUST be converted to lowercase prior to their
encoding in HTTP/2.

Also see: