About this chapter
So far nginx has served files from disk. Now you will put it in front of a running app (Node, Python, Go, anything on a port) and forward requests to it. This is what nginx does on most real servers.
Lessons from courses
- 1 What is a reverse proxy What an nginx reverse proxy is, how a request flows from browser to nginx to your app, and why you put nginx in front of an application.
- 2 proxy_pass Use nginx proxy_pass to forward requests to a Node or other app on a local port, and master the trailing-slash rule that trips people up.
- 3 Passing the real client info Forward the real client IP, host and protocol to your app with nginx proxy_set_header so logging, redirects and rate limits work behind nginx.
- 4 Naming backends with upstream Define an nginx upstream block to name one or more backend servers, then point proxy_pass at the name instead of a hard-coded address.
- 5 Load balancing across backends Set up nginx load balancing across backends: round-robin, weight, least_conn and ip_hash, plus marking servers down or backup.