DevOps and cloud

Stage 2 · Lesson 7 of 8

Nginx as reverse proxy and load balancer

Networking for engineers

A sits in front of your app. It accepts requests from the internet and passes them to the app on a private port. Nginx is the common choice.

It handles TLS, serves static files such as images quickly, and adds such as X-Forwarded-For so the app knows the real visitor's address. With an upstream block it also works as a , spreading traffic across several copies of the app.

A minimal site is a server block with server_name, listen 443 ssl and location / { proxy_pass http://127.0.0.1:3000; }. Always run nginx -t to test the config before reloading, so a typo does not take the site down. A cloud load balancer or a does the same job later, so the ideas carry over.

Common trapforgetting timeouts and body size limits, which show up as mysterious 504s and 413s.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with

Practise

  • Answer its networking questions before reading the answers to find your gaps

Keep handy

  • Official guide to serving files and proxying to an app, the base of every config

  • The HTTP guides on headers, caching and status codes, for debugging proxies

Also worth your time

Mark this stage as not done?