After moving TLS termination to the load balancer, the browser shows `ERR_TOO_MANY_REDIRECTS`.
BeginnerTroubleshootingLoad balancers and reverse proxies
Answer
Likely causes → The LB now talks HTTP to the app. The app sees a plain-HTTP request and redirects to HTTPS; the browser follows, the LB forwards it again as HTTP, and the loop repeats.
Diagnose →
curl -sIL https://app.example.com/ | grep -iE '^(HTTP|location)'
Fix → Make the app trust X-Forwarded-Proto from the LB (Django SECURE_PROXY_SSL_HEADER, Express app.set('trust proxy', 1), Spring server.forward-headers-strategy=native), or do the HTTP→HTTPS redirect on the LB (ALB listener rule on port 80) and remove it from the app. In nginx behind an LB: proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;.
Prevent → Decide which single layer owns the HTTPS redirect and document it.
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