exit lab
DevOps learning path
IntermediateWeb Server

Nginx

The reverse proxy sitting in front of your app — routing, TLS termination, and load distribution.

1 hr

Overview

Nginx sits in front of your application as a reverse proxy — it receives every incoming request first, then forwards it to your Spring Boot or Next.js process running on an internal port.

Why it matters

Your application server usually shouldn't be exposed to the internet directly. Nginx terminates TLS, can serve static files without waking up your app, and gives you one place to configure things like rate limiting and gzip compression instead of building them into every service.

How backend developers use it

A reverse proxy config that listens on 443, terminates HTTPS, and forwards to the Spring Boot app running on 127.0.0.1:8080 — the app itself only needs to bind to localhost, never directly reachable from outside the server.

Common mistakes

Warning

Forwarding the request without setting X-Forwarded-For / X-Forwarded-Proto headers, so the app sees every request as coming from Nginx's IP over plain HTTP, breaking things like audit logs and "detect HTTPS" logic.

Warning

No timeout configuration, so one slow backend request can hold a worker connection open indefinitely.

Warning

Serving static assets through the app server instead of directly from Nginx, wasting the app's threads on work Nginx does faster.

Warning

Editing nginx.conf directly on a production server with no version control — config drift with no way to know what changed or roll it back.

Example commands

Test config syntax before reloading

nginx -t

Reload config without dropping connections

nginx -s reload

Basic reverse proxy block

location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; }

Resources

Retrieval check

Before you continue

  • Explain what this tool or practice changes in the delivery lifecycle.
  • Name one common failure it helps you diagnose or prevent.
  • Repeat one example command from memory, then verify it.