Operations 10 min read

What Can Nginx Do Without Third‑Party Modules? A Practical Guide

This article details the core capabilities of Nginx without third‑party modules, including reverse proxy, various load‑balancing strategies, static and dynamic HTTP serving, forward proxy setup, and hot‑reload commands, providing clear configuration examples for each feature.

Programmer DD
Programmer DD
Programmer DD
What Can Nginx Do Without Third‑Party Modules? A Practical Guide

Introduction

This article explains what Nginx can accomplish without third‑party modules, covering reverse proxy, load balancing, HTTP server (static and dynamic separation), forward proxy, and hot reload commands.

What Nginx Can Do

Reverse proxy

Load balancing

HTTP server (including static and dynamic separation)

Forward proxy

Reverse Proxy

A reverse proxy forwards client requests to internal servers and returns the responses, allowing external access to services that are otherwise inaccessible directly.

server {
    listen 80;
    server_name localhost;
    client_max_body_size 1024M;
    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host:$server_port;
    }
}

Load Balancing

Nginx can distribute requests among multiple backend servers using several built‑in strategies.

1. Round Robin (default)

Requests are assigned to backends sequentially; unavailable servers are automatically skipped.

upstream test {
    server localhost:8080;
    server localhost:8081;
}
server {
    listen 81;
    server_name localhost;
    client_max_body_size 1024M;
    location / {
        proxy_pass http://test;
        proxy_set_header Host $host:$server_port;
    }
}

2. Weight

Assigns a weight to each server; traffic proportionally follows the weight.

upstream test {
    server localhost:8080 weight=9;
    server localhost:8081 weight=1;
}

3. ip_hash

Ensures a client IP always reaches the same backend, useful for session‑affinity.

upstream test {
    ip_hash;
    server localhost:8080;
    server localhost:8081;
}

4. fair (third‑party)

Distributes requests based on backend response time; faster servers receive more traffic.

upstream backend {
    fair;
    server localhost:8080;
    server localhost:8081;
}

5. url_hash (third‑party)

Hashes the request URI to consistently route the same URL to the same backend.

upstream backend {
    hash $request_uri;
    hash_method crc32;
    server localhost:8080;
    server localhost:8081;
}

HTTP Server

Nginx can serve static files directly and proxy dynamic requests to an application server.

server {
    listen 80;
    server_name localhost;
    client_max_body_size 1024M;
    location / {
        root e:\wwwroot;
        index index.html;
    }
    location ~ \.(gif|jpg|jpeg|png|bmp|swf|css|js)$ {
        root e:\wwwroot;
    }
    location ~ \.(jsp|do)$ {
        proxy_pass http://test;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root e:\wwwroot;
    }
}

Forward Proxy

A forward proxy sits between the client and the origin server, forwarding client requests to the target server.

resolver 114.114.114.114 8.8.8.8;
server {
    resolver_timeout 5s;
    listen 81;
    access_log e:\wwwroot\proxy.access.log;
    error_log e:\wwwroot\proxy.error.log;
    location / {
        proxy_pass http://$host$request_uri;
    }
}

Hot Reload

Nginx supports hot reloading; after modifying the configuration, reload without stopping the service. nginx -s reload On Windows the command is:

nginx.exe -s reload
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Operationsload balancingConfigurationNginxHTTP serverreverse proxy
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.