Operations 5 min read

Common Nginx Functions: Static Proxy, Load Balancing, Rate Limiting, Caching, and Access Control

This article explains how Nginx can be used for static file serving, various load‑balancing strategies, rate limiting with the leaky‑bucket algorithm, caching mechanisms, and black‑/white‑list access control, providing practical guidance for improving web service performance and reliability.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Common Nginx Functions: Static Proxy, Load Balancing, Rate Limiting, Caching, and Access Control

1. Static Proxy

Nginx excels at serving static files, making it an ideal image and file server; placing all static resources on Nginx enables separation of static and dynamic content and improves overall performance.

2. Load Balancing

Nginx can act as a reverse proxy to achieve load balancing, preventing single‑node failures by distributing requests according to several common strategies.

• Round Robin – distributes requests sequentially without considering server load.

• Weighted Round Robin – assigns higher weights to more capable or less loaded servers, allowing them to handle more traffic.

• IP Hash (source‑address hash) – hashes the client IP to consistently route the same client to the same backend server as long as the server list remains unchanged.

• Random – selects a backend server at random based on a system‑generated random number.

• Least Connections – routes each request to the server with the fewest active connections, improving utilization.

3. Rate Limiting

Nginx implements rate limiting using the leaky‑bucket algorithm, which is especially useful in high‑concurrency scenarios.

Configuration parameters

limit_req_zone is defined in the http block; $binary_remote_addr stores the client IP in binary form.

• The zone directive creates a shared memory area for IP state and request frequency; for example, a 1 MB zone can store information for about 160 000 IP addresses.

rate sets the maximum request rate, e.g., 100 requests per second.

Setting the limit

Use burst to define the queue size and nodelay to allow requests without spacing.

4. Caching

• Browser cache: static resources can be cached using the expires directive.

• Proxy cache: Nginx can cache responses at the proxy layer to reduce upstream load.

5. Black/White List

• Whitelist (no rate limiting): allows specified IPs to bypass rate‑limiting rules.

• Blacklist: blocks requests from defined IPs.

These are the most commonly used Nginx features: static separation, load balancing, rate limiting, caching, and black/white list control.

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.

load balancingaccess controlcachingNginxWeb serverrate limiting
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

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.