NGINX Cookbook

Book description

A practical book on real-world NGINX deployments to get you up and running quickly.

About This Book

  • Be the first to immerse yourself in the NGINX 1.9x web server and explore the plethora of advanced features.
  • Master the skills of load balancing TCP-based applications and implementing HTTP/2.
  • A recipe-based approach book that provides you with up-to-date information on NGINX, allowing you to implement specific use cases immediately.

Who This Book Is For

This book is aimed at smaller-to-medium developers, who are just getting started with NGINX. It assumes they already understand the basics of how a web server works and how basic networking works.

What You Will Learn

  • Practical, real-world examples and recipes on how to use NGINX
  • Common CMS deployments such as WordPress, Joomla and more
  • NGINX configurations for frameworks such as Ruby on Rails, Django and more
  • Detailed SSL recipes, including HTTP/2
  • Real world rewrite examples
  • Basic web and TCP load balancing configuration
  • Bandwidth management and connection limiting
  • Detailed NGINX deployment scenarios with Docker
  • Performance tuning and monitoring of your NGINX deployments
  • OpenResty deployment guides
  • Advanced deployments with NGINX Plus features

In Detail

NGINX Cookbook covers the basics of configuring NGINX as a web server for use with common web frameworks such as WordPress and Ruby on Rails, through to utilization as a reverse proxy. Designed as a go-to reference guide, this book will give you practical answers based on real-world deployments to get you up and running quickly.

Recipes have also been provided for multiple SSL configurations, different logging scenarios, practical rewrites, and multiple load balancing scenarios. Advanced topics include covering bandwidth management, Docker container usage, performance tuning, OpenResty, and the NGINX Plus commercial features.

By the time you've read this book, you will be able to adapt and use a wide variety of NGINX implementations to solve any problems you have.

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Conventions
    6. Reader feedback
    7. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Let's Get Started
    1. Introduction
    2. A quick installation guide
      1. How to do it...
        1. Packages – RHEL/CentOS
        2. Packages – Debian/Ubuntu
        3. Compiling from scratch
          1. Debian/Ubuntu
          2. CentOS/RHEL
          3. Testing
      2. How to do it...
      3. There's more...
    3. Configuring NGINX
      1. How to do it...
      2. How it works...
    4. Enabling modules
      1. How to do it...
      2. See also
    5. Deploying a basic site
      1. How to do it...
      2. How it works...
    6. Basic monitoring
      1. How to do it...
      2. How it works...
    7. Real-time statistics
      1. How to do it...
      2. How it works...
      3. See also
  3. Common PHP Scenarios
    1. Introduction
    2. Configuring NGINX for WordPress
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. WordPress multisite with NGINX
      1. How to do it...
        1. Subdomains
      2. See also
    4. Running Drupal using NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Using NGINX with MediaWiki
      1. Getting ready
      2. How to do it...
      3. See also
    6. Using Magento with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    7. Configuring NGINX for Joomla
      1. Getting ready
      2. How to do it...
      3. See also
  4. Common Frameworks
    1. Introduction
    2. Setting up Django with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works....
      4. See also
    3. Setting up NGINX with Express
      1. Getting ready
      2. How to do it...
      3. How it works....
      4. See also
    4. Running Ruby on Rails with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Easy Flask with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Laravel via NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    7. Meteor applications with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. High speed Beego with NGINX
      1. Getting ready
      2. How to do it...
  5. All About SSLs
    1. Introduction
    2. Basic SSL certificates
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Enabling HTTP/2 on NGINX
      1. How to do it...
      2. See also
    4. Configuring HSTS in NGINX
      1. How to do it...
      2. There's more...
    5. Easy SSL certificates with Let's Encrypt
      1. How to do it...
      2. See also
    6. Making NGINX PCI DSS compliant
      1. How to do it...
      2. How it works...
      3. See also
    7. OCSP stapling with NGINX
      1. How to do it...
      2. See also
    8. Achieving full A+ Qualys rating
      1. How to do it...
      2. How it works...
      3. See also
  6. Logging
    1. Introduction
    2. Logging to syslog
      1. How to do it...
        1. Remote syslog
      2. See also
    3. Customizing web access logs
      1. How to do it...
      2. See also
    4. Virtual host log format
      1. How to do it...
    5. Application focused logging
      1. How to do it...
    6. Logging TLS mode and cipher information
      1. How to do it...
    7. Logging POST data
      1. How to do it...
    8. Conditional logging
      1. How to do it...
    9. Using the Elastic Stack
      1. How to do it...
        1. Elasticsearch
        2. Logstash
        3. Kibana
      2. See also
  7. Rewrites
    1. Introduction
    2. Redirecting non-www to www-based sites
      1. How to do it...
      2. How it works...
      3. See also
    3. Redirecting to a new domain
      1. How to do it...
      2. How it works...
      3. There's more...
    4. Blocking malicious user agents
      1. How to do it...
      2. How it works...
      3. There's more...
    5. Redirecting all calls to HTTPS to secure your site
      1. How to do it...
      2. There's more...
      3. See also
    6. Redirecting pages and directories
      1. How to do it...
        1. Single page redirect
        2. Full directory redirect
      2. How it works...
      3. See also
    7. Redirecting 404 errors through a search page
      1. How to do it...
      2. How it works...
  8. Reverse Proxy
    1. Introduction
    2. Configuring NGINX as a simple reverse proxy
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Content caching with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Monitoring cache status
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Microcaching
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Serving from cache when your backend is down
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. SSL termination proxy
      1. Getting ready
      2. How to do it...
      3. See also
    8. Rate limiting
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
  9. Load Balancing
    1. Introduction
      1. Basic balancing techniques
    2. Round robin load balancing
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Least connected load balancing
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Hash-based load balancing
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Testing and debugging NGINX load balancing
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    6. TCP / application load balancing
      1. How to do it...
      2. How it works...
        1. Easy testing
      3. There's more...
      4. See also
    7. NGINX as an SMTP load balancer
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
  10. Advanced Features
    1. Introduction
    2. Authentication with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. WebDAV with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Bandwidth management with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Connection limiting with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Header modification with NGINX
      1. Getting ready
      2. How to do it...
        1. Caching static content
        2. Removing server name and version
        3. Extra debug headers
      3. See also
  11. Docker Containers
    1. Introduction
      1. Installing Docker 
    2. NGINX web server via Docker
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. NGINX reverse proxy via Docker
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Docker Compose with NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. NGINX load balancing with Docker
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
  12. Performance Tuning
    1. Introduction
    2. Gzipping content in NGINX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Enhancing NGINX with keep alive
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Tuning worker processes and connections
      1. Getting ready
      2. How to do it...
        1. Worker processes
        2. Worker connections
      3. There's more...
      4. See also
    5. Fine tuning basic Linux system limits
      1. Getting ready
      2. How to do it...
      3. See also
    6. Integrating ngx_pagespeed
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  13. OpenResty
    1. Introduction
    2. Installing OpenResty
      1. Getting ready
      2. How to do it...
        1. CentOS
        2. Ubuntu
      3. How it works...
      4. See also
    3. Getting started with OpenResty Lua
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Lua microservices with OpenResty
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Simple hit counter with a Redis backend
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Powering API Gateways with OpenResty
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  14. NGINX Plus – The Commercial Offering
    1. Introduction
    2. Installing NGINX Plus
      1. Getting ready
      2. How to do it...
        1. CentOS
        2. Ubuntu
      3. See also
    3. Real-time server activity monitoring
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Dynamic config reloading
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Session persistence
      1. Getting ready
      2. How to do it...
        1. Cookie-based tracking
        2. Learn-based tracking
        3. Route-based tracking
      3. How it works...
      4. See also

Product information

  • Title: NGINX Cookbook
  • Author(s): Tim Butler
  • Release date: August 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781786466174