TodayTools

Nginx flashcards

The web server and reverse proxy in front of most sites: serve files, route to apps, add HTTPS, cache and protect.

Donate
Beginner friendly, starts from zero
Section
How to study
0
NginxStart from zero · 1 of 11

What is Nginx, in one plain sentence?

Nginx (said "engine x") is a : a program that waits for browsers to ask for pages and sends them back, very fast and to many people at once.

Engine x: the engine in front of the site.
Show again
11 left
Got it

Tap to turn over. Swipe right if you know it, left to see it again.

All topics

What you will learn

  1. Start from zero

    • What Nginx is4 cards
    • Where you meet it3 cards
    • Key words4 cards
  2. Core basics

    • Install and run3 cards
    • The config file3 cards
    • Sites and static files3 cards
    • Proxying to an app3 cards
    • Logs and errors3 cards
    • Locations2 cards
  3. Next steps

    • HTTPS4 cards
    • Routing paths3 cards
    • Load balancing and WebSockets3 cards
    • Headers, compression and caching3 cards
    • Uploads and error pages2 cards
    • Access control2 cards
  4. Go deeper

    • Location matching3 cards
    • Proxy cache2 cards
    • Rate limits and client IPs2 cards
    • Timeouts, buffers and keepalive3 cards
    • Architecture and protocols3 cards
    • Debugging and hardening4 cards

Final test and certificate

10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.

Take the final test

About these cards

  • Reviewed 26 October 2026
  • Coversnginx 1.30 stablenginx 1.31 mainlineUbuntu 24.04 LTS
How these cards are made

Nginx at a glance

Nginx is a program that sits in front of a website, answers visitors quickly and passes the rest of the work to the right app.

Nginx is the front desk of a big office. It greets every visitor, hands out leaflets itself, and sends people with real business to the right room.

Words you will meet

Web server
A program that sends web pages and files to browsers when they ask
Request
A message from a browser asking for one page, picture or piece of data
Reverse proxy
A server that takes requests and passes them on to another program behind it
Config file
A text file of settings that tells Nginx what to do
Directive
One setting line in the config, ending with a semicolon
Server block
A group of settings for one website name
Location
A group of settings for one set of addresses on a site, like everything under /api
Upstream
The app or apps behind Nginx that do the real work

The steps

  1. 1. Start from zero (11 cards): What Nginx is, why sites use it, and the handful of words the rest of the topic uses.
  2. 2. Core basics (17 cards): Install, the config file, server and location blocks, static files, proxying to an app, logs and safe reloads.
  3. 3. Next steps (17 cards): HTTPS, redirects, single page apps, WebSockets, load balancing, compression, headers, uploads and error pages.
  4. 4. Go deeper (17 cards): Location matching rules, caching, rate limits, real client IPs, timeouts, workers, HTTP/2 and HTTP/3, debugging and security.
All 11 cards in Start from zero
What is Nginx, in one plain sentence?
Nginx (said "engine x") is a web server: a program that waits for browsers to ask for pages and sends them back, very fast and to many people at once.
What is a web server doing when you open a website?
Your browser sends a request, like "give me the home page". The web server finds the page or asks an app to make it, then sends the answer back. This happens for every page, picture and file.
Why not let the app itself talk to visitors directly?
Apps are good at business logic but weak at handling thousands of slow visitors, HTTPS and files. Nginx handles that crowd cheaply and passes only real work to the app.
What is a reverse proxy, in everyday terms?
A reverse proxy is a middleman on the server side. Visitors talk only to it, and it quietly passes each request to the right program behind it and returns the answer.
Where might you meet Nginx without knowing it?
Shopping sites, news sites, school portals and many apps on your phone talk to servers that sit behind Nginx. Docker images, cloud servers and Kubernetes clusters often ship it too.
You see a plain page saying "502 Bad Gateway" and "nginx". What happened?
Nginx was working, but the app behind it did not answer properly, often because the app crashed or was restarting. The front desk is open; the back office is not.
What is the Nginx config file?
A plain text file, usually /etc/nginx/nginx.conf, full of settings. Nginx reads it when it starts or reloads and does exactly what it says.
What is a directive?
One setting in the config: a name, a value and a semicolon at the end, like listen 80;. Forgetting the semicolon is the most common first mistake.
What are server blocks and location blocks?
A server block holds the settings for one website name, like shop.example.com. Inside it, location blocks hold settings for parts of the site, like everything under /images/.
What is an upstream?
The app or group of apps that Nginx passes requests to, like a Python app on port 8000. Nginx is downstream, closer to the visitor; the app is upstream.
What do you need before learning Nginx, and what will you be able to do?
You need to be able to type commands in a terminal and edit a text file. After this topic you can put a site online with HTTPS, route requests to apps and fix the common errors.
Nginx cheatsheet

Commands

  • sudo nginx -t Test config, change nothing
  • sudo systemctl reload nginx Apply config with no downtime
  • sudo nginx -T Print full config with includes
  • nginx -V Version and built-in modules
  • tail -f /var/log/nginx/error.log Watch errors live
  • sudo certbot --nginx -d example.com Get and install a certificate

Server basics

  • listen 443 ssl; HTTPS on TCP 443
  • http2 on; Enable HTTP/2
  • server_name example.com www.example.com; Names this block answers
  • root /var/www/site; Folder for static files
  • return 301 https://$host$request_uri; Redirect to HTTPS
  • listen 80 default_server; return 444; Drop unknown hosts

Locations

  • location = /health Exact match, checked first
  • location ^~ /static/ Prefix that skips regex
  • location ~* \.(png|jpg)$ Regex, case-insensitive
  • location / Fallback prefix
  • try_files $uri $uri/ /index.html; Single page app fallback
  • alias /srv/files/; Replace prefix with a folder

Proxy

  • proxy_pass http://127.0.0.1:8000; Send to app, keep path
  • proxy_set_header Host $host; Pass the site name
  • proxy_set_header X-Forwarded-Proto $scheme; Tell app it was HTTPS
  • proxy_http_version 1.1; Needed for keepalive and WebSockets
  • proxy_read_timeout 120s; Wait longer for slow app
  • proxy_buffering off; Stream responses at once

Protect and speed up

  • client_max_body_size 20m; Allow bigger uploads
  • limit_req zone=login burst=3 nodelay; Apply a rate limit
  • gzip on; gzip_types application/json ...; Compress text
  • add_header X-Content-Type-Options nosniff always; Header on every status
  • server_tokens off; Hide version number
  • proxy_cache_use_stale error timeout updating; Serve old copy on failure
Donate