Node.js › Cloud & DevOps
What is a reverse proxy, and why is Nginx commonly placed in front of a Node.js application in production?
IntermediateAnswer
A reverse proxy forwards client requests to backend servers -- Nginx is placed in front of Node.js to handle TLS termination, serve static files directly, provide basic load balancing, and buffer slow client connections so they can't tie up limited Node.js concurrency.
server {
listen 443 ssl;
location /static/ { root /var/www; }
location / { proxy_pass http://localhost:3000; }
}Real-world example A production API runs behind Nginx, which handles TLS certificates and serves static assets directly without involving the Node.js process at all.