NGINX is one of the most widely used web servers available today, in part because of its capabilities as a load balancer and reverse proxy server for HTTP and other network protocols. This revised cookbook provides easy-to-follow examples of real-world problems in application delivery. Practical recipes help you set up and use either the open source or commercial offering to solve problems in various use cases.
For professionals who understand modern web architectures, such as n-tier or microservice designs and common web protocols such as TCP and HTTP, these recipes provide proven solutions for security and software load balancing and for monitoring and maintaining NGINX’s application delivery platform. You’ll also explore advanced features of both NGINX and NGINX Plus, the free and licensed versions of this server.
You’ll find recipes for:
• High-performance load balancing with HTTP, TCP, and UDP
• Securing access through encrypted traffic, secure links, HTTP authentication subrequests, and more
• Deploying NGINX to Google, AWS, Azure cloud, and DigitalOcean
• Installing and configuring the NGINX App Protect module
• HTTP/3 (QUIC), OpenTelemetry, and the njs module
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A practical recipe collection for engineers who already understand HTTP, TCP, and modern multi-tier or microservice architectures and now need to configure NGINX or NGINX Plus for real production traffic. It is best suited to operators, SREs, and backend engineers who want proven patterns for load balancing, caching, security, cloud deployment, and observability rather than a from-scratch introduction to web serving.
【Book Arc】
- **Opening (~0%–9%)**: Establishes the cookbook format and the scope of both NGINX Open Source and NGINX Plus, then previews the full recipe map: load balancing, traffic management, caching, security, cloud deployment, App Protect, HTTP/3, OpenTelemetry, and njs.
- **Early (~16%–34%)**: Covers the operational basics—process model, key files and commands, `include` organization, serving static content—then moves into high-performance load balancing with HTTP, TCP, and UDP upstreams, balancing methods, sticky cookies, and passive health checks.
- **Middle (~38%–47%)**: Shifts to traffic management and scale: GeoIP/GeoIP2 access control, rate limiting, and massively scalable content caching with cache zones, cache locking, stale cache, and cache slicing for large media.
- **Late**: The excerpts indicate later chapters on high-availability deployment modes, advanced activity monitoring, debugging and troubleshooting with access/error logs and request tracing, and performance tuning, but the sampled material does not cover their detailed recipes.
- **Ending**: The book closes with performance tuning topics such as load-driver testing, browser and upstream connection reuse, response and log buffering, and OS-level tuning, followed by an index.
【Key Takeaways】
- **NGINX is configured as a hierarchy of contexts** (Early): `http`, `server`, and `location` blocks define what is listened for and how requests are routed; understanding this structure is the prerequisite for every later recipe.
- **`include` statements are the main tool for keeping configuration maintainable** (Early): shared FastCGI or SSL snippets can be written once and reused across virtual servers, avoiding duplication in large configs.
- **Load balancing is upstream-centric** (Early): the `upstream` module defines pools of Unix sockets, IPs, or hostnames, and per-server parameters such as weight control routing; methods include round-robin, least connections, least time, generic hash, random, and IP hash.
- **Sticky sessions and health checks have open-source versus Plus trade-offs** (Early): sticky cookie affinity is an NGINX Plus feature, while passive health checking with `max_fails` and `fail_timeout` works in Open Source across HTTP, TCP, and UDP.
- **Traffic management is policy-driven** (Middle): GeoIP/GeoIP2 variables can log, route, or restrict by country, and `limit_req_zone` with `limit_req` enforces request-rate limits, typically returning a 4xx status such as 429.
- **Caching needs concurrency and freshness controls** (Middle): `proxy_cache_path` defines storage, `proxy_cache_lock` prevents duplicate cache fills, `proxy_cache_use_stale` serves expired content when upstreams fail, and cache slicing efficiently handles large byte-range resources like HTML5 video.
- **Monitoring and debugging are first-class recipes** (Late): stub status, the NGINX Plus dashboard and API, OpenTelemetry, and Prometheus exporter cover metrics, while access logs, error logs, syslog forwarding, config debugging, and request tracing cover diagnosis.
- **Performance tuning spans client, upstream, logging, and OS layers** (Ending): connection keepalive, response buffering, access-log buffering, and OS tuning are presented as complementary levers rather than a single fix.
【Reading Tips】
- Treat the early basics as a reference, not a tutorial: if you already run NGINX, skim the process-model and key-files recipes and deep-read the upstream, sticky, and health-check sections.
- Read the load-balancing and caching chapters together, because upstream behavior and cache behavior interact heavily in production traffic patterns.
- Pay attention to Open Source versus NGINX Plus labels; several recipes, including sticky cookie and some monitoring features, are Plus-only and will not work on the free build.
- Use the later monitoring, debugging, and performance-tuning recipes as an operational checklist when you move a configuration from staging to production.
- Keep the book nearby as a lookup cookbook: the value is in the specific directives and trade-offs, not in linear reading.
【Coverage Limits】
This guide is based on stratified excerpts that cover the opening, early, and middle material in detail, while the later chapters on high availability, monitoring, debugging, and performance tuning are only visible through the table of contents. Specific recipes, configurations, and examples from those later chapters are not covered here.
Excerpt 1
al sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: John Devins Indexer: Potomac Indexing, LLC Development Editor: Gary O’Brien...
ite this configuration once and include it wherever needed. By logically grouping your configurations together, you can rest assured that your configurations...
failed or timed-out connections as they pass through NGINX as requested by a client. Passive health checks are enabled by default; the parameters mentioned h...
he entries when the upstream sever is unavailable. Solution Use the proxy_cache_use_stale directive with a parameter value defining for which cases NGINX sho...
into place to activate this feature: $ wget https://github.com/nginxinc/nginx-saml/archive/refs/heads/main.zip \ -O nginx-saml-main.zip $ unzip nginx-saml-ma...
sets the Strict-Transport-Security header to a max age of a year. This will instruct the browser to always do an internal redirect when HTTP requests are att...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Loading comments...
Reply to Comment
Edit Comment