What is the role of reverse proxies in Express.js production deployments?

Answer

In production, Express typically runs behind a reverse proxy (Nginx, Apache, or a load balancer). The proxy handles: SSL termination (manages HTTPS, Express only sees HTTP internally). Static file serving (far more efficient than Express static middleware). Load balancing across multiple Node.js instances. Compression (gzip at proxy level). Connection limiting and request buffering. Configure Express to trust the proxy's forwarded headers: app.set('trust proxy', 1) — this ensures req.ip returns the client's real IP (not the proxy's) and req.secure correctly reflects HTTPS. Without this setting, rate limiting by IP and HTTPS redirects break behind a proxy.