What Is Nginx
Introduction
Nginx (pronounced “engine-x”) is software that answers HTTP requests on the public internet—or on your LAN—and decides what to do with each request. It can serve HTML and assets directly, forward traffic to your Spring Boot or Node app, spread load across several backends, and terminate HTTPS. This chapter explains what Nginx is, where it fits in a typical stack, and how this tutorial track relates to the Linux and application courses on Hello Code.
Prerequisites
- Basic idea of HTTP (browser requests a URL, server returns a response)
- No Nginx installation required yet for this overview
- Helpful background: What Is Linux if you deploy on a VPS
Nginx in One Sentence
Nginx is a high-performance web server and reverse proxy that sits in front of your applications and handles connections efficiently at scale.
Most teams use it for at least one of these jobs:
| Role | What Nginx does |
|---|---|
| Web server | Serves static files (index.html, CSS, JS, images) |
| Reverse proxy | Accepts port 80/443, forwards to 127.0.0.1:8080 or :3000 |
| Load balancer | Distributes requests across multiple app instances |
| TLS termination | Handles HTTPS certificates; apps speak plain HTTP locally |
One Nginx process can combine several roles on the same machine.
A Typical Request Path
Browser Nginx Your app
│ │ │
│ GET https://app.com/ │ │
├────────────────────────►│ │
│ │ proxy_pass → :8080 │
│ ├─────────────────────────►│
│ │◄─────────────────────────┤
│◄────────────────────────┤ JSON / HTML │
│ 200 OK │ │Code explanation:
- The client only talks to Nginx on ports 80 (HTTP) or 443 (HTTPS)
- Nginx forwards to a backend bound to localhost—Java, Node, Python, etc.
- The backend does not need to manage public TLS or expose high ports directly
Tip
Bind Apps to Localhost
Run Spring Boot on 127.0.0.1:8080 and Node on 127.0.0.1:3000, then let Nginx face the world. Pair with a firewall that blocks those ports from the internet.
Why Nginx Is Popular
| Strength | Practical effect |
|---|---|
| Event-driven architecture | Handles many concurrent connections without one thread per client |
| Low memory footprint | Fits small VPS instances |
| Stable static file performance | Efficient for frontends built with Vite, React, or plain HTML |
| Mature reverse proxy | Standard choice in front of Java and Node APIs |
| Wide documentation and examples | Easy to find configs for common patterns |
Nginx is not the only option—but it is one of the most common on Linux servers.
Nginx vs Other Web Front Ends
| Software | Strengths | Typical use |
|---|---|---|
| Nginx | Speed, static files, reverse proxy, load balance | VPS, traditional deploy |
| Apache httpd | Rich modules, .htaccess per directory | Shared hosting, legacy PHP stacks |
| Caddy | Automatic HTTPS by default, simple config | Small projects, quick TLS |
| Traefik | Dynamic config with Docker/Kubernetes labels | Container orchestration |
For Hello Code projects—static HTML/CSS sites, Spring Boot JARs, Node APIs on a single VPS—Nginx is an excellent default. Caddy is a friendly alternative when you want minimal TLS setup; Traefik shines when everything runs in Kubernetes.
This track teaches Nginx configuration and operations in depth. The Linux track includes a short Nginx deploy chapter for readers who only need a quick path to production.
Master-Worker Process Model (Concept)
Nginx runs as:
master process ──► reads config, manages workers
│
├── worker 1 ──► handles client connections
├── worker 2
└── worker NCode explanation:
- The master loads
/etc/nginx/nginx.confand spawns workers - Workers accept connections and serve or proxy requests
- Reloading config (
nginx -s reloadorsystemctl reload nginx) lets workers pick up changes without long downtime
You rarely tune this on day one; later chapters mention worker_processes and connection limits.
Common Scenarios on Hello Code
| Your project | How Nginx helps |
|---|---|
| HTML/CSS static site | Serve dist/ or public/ from disk |
| Spring Boot JAR on port 8080 | proxy_pass to the JVM process |
| Node.js on port 3000 | Same pattern for Express/Fastify |
| Multiple domains on one VPS | Separate server blocks per server_name |
| HTTPS for production | Certbot + Nginx or manual ssl_certificate |
Nginx does not replace your application—it fronts it. You still build and run Java, Node, or static files; Nginx routes traffic and adds TLS, caching headers, and gzip.
What Nginx Is Not
- Not a programming language — configuration lives in
.conffiles, not Java or JavaScript - Not a database — it does not store user data (except optional cache on disk)
- Not a replacement for Linux skills — you install and control it with
apt,systemd, and SSH from the Linux track - Not required for local dev —
npm run devandspring-boot:runwork without Nginx until you deploy
How This Tutorial Is Organized
This Nginx track follows frontend/gen_article_plan/nginx.md:
- Install and config syntax — directories,
nginx -t, first virtual host - Static sites and frontends —
try_files, SPA routing, gzip, cache headers - Reverse proxy and HTTPS — Spring Boot, Node, Let's Encrypt
- Routing, logs, security, performance — location blocks, troubleshooting, rate limits
- Projects — static + TLS, SPA + API, multi-domain, simple load balancing
Examples assume Ubuntu LTS / Debian package installs (apt install nginx). RHEL-family systems use dnf install nginx with similar paths; differences are noted when they matter.
Warning
Practice on a Real Linux Shell
Nginx configuration exercises require Linux (VPS, VM, or WSL2). Config syntax on paper is not enough—you need nginx -t and curl on a running instance.
Mini Example: What You Will Eventually Configure
You do not need to run this yet—it previews the shape of a real site block:
server {
listen 80;
server_name example.com;
root /var/www/example;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}Code explanation:
listen 80— accept HTTP on port 80server_name— match requests for this hostnameroot— folder on disk for static fileslocation /— default handler;try_fileslooks for a file, then a directory, else 404
Later chapters replace or extend this with proxy_pass, SSL, and multiple locations.
Related Hello Code tracks for SPA deploy: Vue Build and Deploy, Vue Docker and CI—try_files for Vue Router history mode.
FAQ
Is Nginx free?
Yes. Nginx open source is free to use. Nginx Plus is a commercial product with extra features and support; this tutorial covers the open source version.
Do I need Nginx on my laptop for learning Java or Node?
No for day-to-day coding. You need it when you deploy to a server or when you want production-like HTTPS and routing locally.
Nginx vs Apache—which should I learn first?
If your goal is modern VPS deploy with Spring Boot, Node, or static SPAs, Nginx is the better first choice on this site. Apache remains useful in legacy hosting environments.
Can Nginx run on Windows?
Yes, but production deploys in this track focus on Linux. Most Hello Code server examples use Ubuntu.
Is Nginx the same as Docker?
No. Docker packages applications in containers. Nginx often runs on the host or inside a container to route traffic—you will see both patterns in later chapters.
What is the difference between this track and Linux chapter 15?
Linux chapter 15 is a quick deploy guide. This Nginx track goes deeper: config structure, HTTPS, location routing, logs, security, and multiple hands-on projects.
Does Nginx support HTTP/2 and HTTP/3?
HTTP/2 is commonly enabled with listen 443 ssl http2. HTTP/3 (QUIC) requires additional modules and setup—not covered in the first chapters but supported in newer Nginx builds.