After enabling PROXY protocol on nginx, every request fails and the log shows `broken header: "GET / HTTP/1.1"` while reading PROXY protocol.
IntermediateTroubleshootingLoad balancers and reverse proxies
Answer
Likely causes → nginx expects a PROXY protocol header (listen 80 proxy_protocol;) but the sender (LB, health checker, or you testing with curl) sends plain HTTP. Both sides must agree.
Diagnose →
aws elbv2 describe-target-group-attributes --target-group-arn <tg> \
--query "Attributes[?Key=='proxy_protocol_v2.enabled']"
curl -v --haproxy-protocol http://127.0.0.1/ # test as if from a PROXY-enabled LB
Fix → Enable PROXY protocol v2 on the NLB target group (or send-proxy-v2 in HAProxy), or remove proxy_protocol from the listen directive. If health checks can't send it, put them on a separate listen port without PROXY protocol.
Prevent → Change the sender and receiver in the same rollout, behind a separate port first.
More on Load balancers and reverse proxies
nginx returns `502 Bad Gateway` and the error log says `connect() failed (111: Connection refused) while connecting to upstream`.Beginnernginx returns `504 Gateway Time-out` with `upstream timed out (110: Connection timed out) while reading response header from upstream`.BeginnerAn ALB target group shows all targets `unhealthy` with `Health checks failed with these codes: [404]`.BeginnerAn ALB returns sporadic `502`s, and access logs show `elb_status_code=502` with `target_status_code=-`. Load is low.Intermediatenginx logs `upstream prematurely closed connection while reading response header from upstream`.Intermediatenginx error log shows `no live upstreams while connecting to upstream` and every request gets 502.Intermediate