@willy can you take a look at this. In HTX mode we are generally stricter and the HTTP response has numerous issues, but can you tell:
- why replaying the same response we get different error positions (maybe timing related)
- it is unclear what error haproxy is seeing at position 176 in the OP’s output
- it is unclear why the error position for my output points to 288 when really the double colon of the previous content-length header triggered the error
The OP’s error:
"backend xxx_backend (#7): invalid response
frontend xxxx (#4), server xxx (#1), event #0, src x.x.x.x:35312
buffer starts at 0 (including 0 out), 64 free,
len 16320, wraps at 16336, error at position 176
H1 connection flags 0x00000020, H1 stream flags 0x00004044
H1 msg state MSG_HDR_L2_LWS(24), H1 msg flags 0x00001414
H1 chunk len 0 bytes, H1 body len 0 bytes :
00000 HTTP/1.1 200 OK\r\n
00017 Server: Apache-Coyote/1.1\r\n
00044 Content-Description:\xC0[\x95\x02\x00\x00\x00\x00\xC0\xF4\x8B\x00\x00
00077+ \x00\x00\x00\xD0[\x95\x02\x00\x00\x00\x00 ~\x8B\x00\x00\x00\x00\x00
00096+ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFFHTTP/1
00118+ .1 200 OK\r\n
00129 Server: Apache-Coyote/1.1\r\n
00156 Content-Description: File Transfer\r\n
00192 Content-Disposition: attachment;filename=xxxxxx
00261+ \r\n
00263 Content-Length:: 137358\r\n
00288 Content-Transfer-Encoding: binary \r\n
00324 Expires: 0\r\n
00336 Content-Type: application/octet-stream\r\n
00376 Transfer-Encoding: chunked\r\n
00404 Date: Mon, 23 Dec 2019 17:59:55 GMT\r\n
00441 Connection: close\r\n
Note: the filename in the Content-Disposition header at offset 192 has been shortened for sensitivity.
My error (replaying the same response with netcat):
lukas@dev:~$ echo "show errors" | socat stdio /tmp/haproxy
Total events captured on [25/Dec/2019:20:19:45.737] : 1
[25/Dec/2019:20:19:43.901] backend nc (#3): invalid response
frontend myfrontend (#2), server nc (#1), event #0, src 10.0.0.4:51124
buffer starts at 0 (including 0 out), 15924 free,
len 460, wraps at 16336, error at position 288
H1 connection flags 0x00000000, H1 stream flags 0x0000401c
H1 msg state MSG_HDR_L2_LWS(24), H1 msg flags 0x00001414
H1 chunk len 0 bytes, H1 body len 0 bytes :
00000 HTTP/1.1 200 OK\r\n
00017 Server: Apache-Coyote/1.1\r\n
00044 Content-Description:\xC0[\x95\x02\x00\x00\x00\x00\xC0\xF4\x8B\x00\x00
00077+ \x00\x00\x00\xD0[\x95\x02\x00\x00\x00\x00 ~\x8B\x00\x00\x00\x00\x00
00096+ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFFHTTP/1
00118+ .1 200 OK\r\n
00129 Server: Apache-Coyote/1.1\r\n
00156 Content-Description: File Transfer\r\n
00192 Content-Disposition: attachment;filename=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
00261+ \r\n
00263 Content-Length:: 137358\r\n
00288 Content-Transfer-Encoding: binary \r\n
00324 Expires: 0\r\n
00336 Content-Type: application/octet-stream\r\n
00376 Transfer-Encoding: chunked\r\n
00404 Date: Mon, 23 Dec 2019 17:59:55 GMT\r\n
00441 Connection: close\r\n
lukas@dev:~$
Replaying response on port 8080:
echo -ne \
'HTTP/1.1 200 OK\r\nServer: Apache-Coyote/1.1\r\nContent-Description:\xC0[\x95\x02\x00\x00\x00\x00\xC0\xF4\x8B\x00\x00\x00\x00\x00\xD0[\x95\x02\x00\x00\x00\x00 ~\x8B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFFHTTP/1.1 200 OK\r\nServer: Apache-Coyote/1.1\r\nContent-Description: File Transfer\r\nContent-Disposition: attachment;filename=xxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\nContent-Length:: 137358\r\nContent-Transfer-Encoding: binary \r\nExpires: 0\r\nContent-Type: application/octet-stream\r\nTransfer-Encoding: chunked\r\nDate: Mon, 23 Dec 2019 17:59:55 GMT\r\nConnection: close\r\n\r\n' \
> pbrownBogusOriginalResponse.http
while true; do cat pbrownBogusOriginalResponse.http | nc -l 8080; done
Config:
global
log 10.0.0.4 syslog debug
stats socket /tmp/haproxy mode 666 level admin
defaults
#option accept-invalid-http-response
option http-use-htx
mode http
timeout connect 3s
timeout http-request 20s
timeout http-keep-alive 30s
timeout client 10s
timeout server 70s
frontend myfrontend
bind :80
option httplog
log global
use_backend nc
backend nc
server nc 127.0.0.1:8080