What's the difference between proxy_pass as a reverse proxy vs a load balancer in NGINX?
⚡
Quick Answer
A single upstream URL proxies to one backend; an upstream block with multiple servers load-balances across them.
Detailed Answer
reverse proxy: proxy_pass to one backend to terminate TLS, cache, or route. Load balancing: define an upstream with several servers and proxy_pass to it; NGINX distributes requests (round-robin by default, or least_conn, ip_hash) and can health-check and mark servers down.
Code Example
upstream app { least_conn; server a:8080; server b:8080; }
location / { proxy_pass http://app; }💡
Interview Tip
upstream{} block is the load-balancing mechanism.
nginxreverse-proxyload-balancing