Interview Prep/Networking/Load balancers and reverse proxies

A gRPC service behind nginx returns 502 and the log says `upstream sent no valid HTTP/1.0 header while reading response header from upstream`.

AdvancedTroubleshootingLoad balancers and reverse proxies
Answer

Likely causes → nginx is configured with proxy_pass, which speaks HTTP/1.x to upstreams, but the gRPC server only speaks HTTP/2 (h2c). The server answers with HTTP/2 frames, which nginx can't parse as an HTTP/1 response.

Diagnose →

nginx -T | grep -B5 -A5 'proxy_pass.*50051'
grpcurl -plaintext 127.0.0.1:50051 list     # confirm the backend works directly

Fix →

server {
    listen 443 ssl;
    http2 on;
    location / {
        grpc_pass grpc://127.0.0.1:50051;   # grpcs:// if the backend uses TLS
        grpc_read_timeout 300s;
    }
}

Prevent → Use protocol-aware proxies for gRPC (nginx grpc_pass, Envoy, ALB target groups with protocol version GRPC).

All Networking questions Roadmap: Networking for DevOps

More on Load balancers and reverse proxies