Express Proxy Trust
Question Variations
- "Why might `req.secure` be false behind a TLS load balancer?"
- "What security issue can an overly broad `trust proxy` setting cause?"
- "How should proxy trust be configured in a multi-proxy deployment?"
Why This Is Asked
Most deployed Express services sit behind a reverse proxy or load balancer. This question tests whether you know which forwarding headers are trustworthy and how a bad proxy configuration can affect security-sensitive logic.
Key Concepts
- Proxies commonly add
X-Forwarded-ForandX-Forwarded-Protoheaders. trust proxycontrols whether Express uses those headers for values such asreq.ipandreq.secure.- Trust only known network hops, not arbitrary client-provided forwarding headers.
- Correct proxy trust is required for secure-cookie and client-IP based policies behind TLS termination.
Question Variations
- “Why might
req.securebe false behind a TLS load balancer?” - “What security issue can an overly broad
trust proxysetting cause?” - “How should proxy trust be configured in a multi-proxy deployment?”