HAProxy community

502 Bad Gateway - PH-- - Haproxy 1.8


I’m trying to use Haproxy 1.8 on debian 10 distrib (buster) with an apache backend.

When I try to Access a page in which we set a cookie, I’m encountering a 502 Bad Gateway.

Looking at the log, I can see that it’s a PH-- error so answer of server seems to be the cause but I haven’t any other clue.

Activating debug mode didn’t help me.

I’ve tried in tcp mode it works but I can’t use or because my routing is based on http header.

Tried with apache with proxy mode activated and it works fine.

I’ve also tried to accept Bad request ans réponse in option also to set “no option checkcache” even if “option checkcache IS not set anywhere” but it also didn’t work

Any ideas of the issue?

You need to configure the admin socket and then issue a show errors on the admin socket.


Hi Lukastribus,

Thanks for your quick answer.

Using admin socket, I was able to display following error logs

[29/Jan/2020:10:27:35.699] backend plateformefr (#4): invalid response
frontend myfrontend(#3), server node1 (#1), event #0
src myip:8687, session #5, session flags 0x001004ce
HTTP msg state MSG_HDR_L2_LWS(24), msg flags 0x00000000, tx flags 0xa8003000
HTTP chunk len 0 bytes, HTTP body len 0 bytes
buffer flags 0x80008002, out 0 bytes, total 13025 bytes
pending 13025 bytes, wrapping at 16384, error at position 11050:

10887 Set-Cookie: value1=value; expires=Fri, 31-Jan-2020 09:27:35 GMT; Max-Age
10957+ =172800\r\n
10966 Set-Cookie: value2=value; expires=Fri, 31-Jan-2020 09:27:35 GMT; Ma
11036+ x-Age=172800\r\n
11050 Set-Cookie: value3=value; expires
11120+ =Fri, 31-Jan-2020 09:27:35 GMT; Max-Age=172800\r\n
11168 Set-Cookie: value4=value; expires=Fri, 31-Jan-2020 09:27:3
11238+ 5 GMT; Max-Age=172800\r\n

N.B: confidential values replaced by value

I’m surely missing a weird things but I don’t understand what could be the issue.

It is unclear and impossible to tell what the issue here is with the values you have replaced, but I assume, based on the error position that it’s about the second Set-Cookie line with value2, given that the error position is 11050 (at the beginning of the third).

You’d have to provide more information. At least explain what those values look like? Are these release alphanumerical characters only?


Thanks for your answer.

The issue was due to the oversizing of the HTTP header.

Setting “tune.http.maxhdr” to 8192 has resolv the issue.

Thanks again for your help and for your advice with “show errors”.

1 Like