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:

RoleWhat Nginx does
Web serverServes static files (index.html, CSS, JS, images)
Reverse proxyAccepts port 80/443, forwards to 127.0.0.1:8080 or :3000
Load balancerDistributes requests across multiple app instances
TLS terminationHandles HTTPS certificates; apps speak plain HTTP locally

One Nginx process can combine several roles on the same machine.

A Typical Request Path

text
  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.

StrengthPractical effect
Event-driven architectureHandles many concurrent connections without one thread per client
Low memory footprintFits small VPS instances
Stable static file performanceEfficient for frontends built with Vite, React, or plain HTML
Mature reverse proxyStandard choice in front of Java and Node APIs
Wide documentation and examplesEasy 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

SoftwareStrengthsTypical use
NginxSpeed, static files, reverse proxy, load balanceVPS, traditional deploy
Apache httpdRich modules, .htaccess per directoryShared hosting, legacy PHP stacks
CaddyAutomatic HTTPS by default, simple configSmall projects, quick TLS
TraefikDynamic config with Docker/Kubernetes labelsContainer 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:

text
  master process  ──► reads config, manages workers

        ├── worker 1  ──► handles client connections
        ├── worker 2
        └── worker N

Code explanation:

  • The master loads /etc/nginx/nginx.conf and spawns workers
  • Workers accept connections and serve or proxy requests
  • Reloading config (nginx -s reload or systemctl 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 projectHow Nginx helps
HTML/CSS static siteServe dist/ or public/ from disk
Spring Boot JAR on port 8080proxy_pass to the JVM process
Node.js on port 3000Same pattern for Express/Fastify
Multiple domains on one VPSSeparate server blocks per server_name
HTTPS for productionCertbot + 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 .conf files, 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 devnpm run dev and spring-boot:run work without Nginx until you deploy

How This Tutorial Is Organized

This Nginx track follows frontend/gen_article_plan/nginx.md:

  1. Install and config syntax — directories, nginx -t, first virtual host
  2. Static sites and frontendstry_files, SPA routing, gzip, cache headers
  3. Reverse proxy and HTTPS — Spring Boot, Node, Let's Encrypt
  4. Routing, logs, security, performance — location blocks, troubleshooting, rate limits
  5. 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:

nginx
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 80
  • server_name — match requests for this hostname
  • root — folder on disk for static files
  • location / — default handler; try_files looks 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 CItry_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.