Nginx Essentials

Book description

Excel in Nginx quickly by learning to use its most essential features in real-life applications

In Detail

Nginx is an open source and cross-platform reverse proxy server designed for low memory usage and high performance and concurrency.

This book provides both basic and in-depth knowledge to help you effectively solve challenges with Nginx, or comfortably go through a transition period when switching to Nginx.

Starting with the basics, you will learn by example how to set up, configure, and operate an Nginx installation and use features of Nginx to elegantly solve challenges you experience every day when running your website. You will learn to use the rewrite engine to solve day-to-day tasks and be able to configure access restrictions in Nginx. You will also be able to manage inbound traffic using a number of Nginx features and use Nginx for load balancing and fault-tolerance features. Finally, you will learn how to solve common performance problems and apply a number of performance-tuning strategies.

Through easy exploration of the most intricate topics, this book aims to bring you to the next level in your Nginx experience.

What You Will Learn

  • Get started with an Nginx installation from scratch in various environments and customize it for your purposes
  • Start and stop a basic Nginx installation, discover the basics of process management, and learn how to set up Nginx to serve static data
  • Create highly-maintainable configuration files to perform the most critical Nginx maintenance tasks
  • Set up Nginx as a reverse proxy and learn to use the Nginx caching feature
  • Discover how to benefit from the Nginx rewrite engine and how to use access restrictions in Nginx
  • Use various Nginx features to manage inbound traffic and understand how to use Nginx load balancing and fault tolerance features
  • Understand advanced feature-independent performance tuning strategies and optimizations
  • Manage inbound and outbound traffic and configure access control

Table of contents

  1. Nginx Essentials
    1. Table of Contents
    2. Nginx Essentials
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. eBooks, discount offers, and more
        4. Questions
    8. 1. Getting Started with Nginx
      1. Installing Nginx
        1. Installing Nginx on Ubuntu
          1. Alternatives
        2. Installing Nginx on Red Hat Enterprise Linux or CentOS/Scientific Linux
        3. Installing Nginx from source files
          1. Downloading the Nginx source files
            1. Troubleshooting
          2. Building Nginx
            1. Troubleshooting
          3. Copying the source code configuration from prebuilt packages
        4. The structure of the Nginx installation
          1. The Nginx configuration folder
          2. The default virtual host folder
          3. The virtual hosts configuration folder
          4. The log folder
          5. The temporary folder
      2. Configuring Nginx
        1. Value types
        2. Variables
        3. Inclusions
        4. Sections
        5. The http section
        6. The server section
        7. The upstream section
        8. The location section
          1. Simple
          2. Exact
          3. Regular expression locations
        9. The if section
        10. The limit_except section
        11. Other section types
        12. Configuration settings' inheritance rules
        13. The First sample configuration
        14. Configuration best practices
      3. Summary
    9. 2. Managing Nginx
      1. The Nginx connection processing architecture
      2. Starting and stopping Nginx
      3. Control signals and their usage
        1. Fast shutdown
        2. Graceful shutdown
        3. Reconfiguration
        4. Reopening the log file
        5. Nginx binary upgrade
        6. Graceful worker shutdown
        7. Finalizing the upgrade procedure
        8. Handling difficult cases
      4. Distribution-specific startup scripts
      5. Allocating worker processes
      6. Setting up Nginx to serve static data
      7. Installing SSL certificates
        1. Creating a Certificate Signing Request
        2. Installing an issued SSL certificate
        3. Permanently redirecting from a nonsecure virtual host
      8. Managing temporary files
      9. Communicating issues to developers
        1. Creating a binary with debugging information
      10. Summary
    10. 3. Proxying and Caching
      1. Nginx as a reverse proxy
      2. Setting up Nginx as a reverse proxy
        1. Setting the backend the right way
        2. Adding transparency
        3. Handling redirects
        4. Handling cookies
        5. Using SSL
        6. Handling errors
        7. Choosing an outbound IP address
        8. Accelerating downloads
      3. Caching
        1. Configuring caches
        2. Enabling caching
        3. Choosing a cache key
        4. Improving cache efficiency and availability
        5. Handling exceptions and borderline cases
      4. Summary
    11. 4. Rewrite Engine and Access Control
      1. The basics of the rewrite engine
        1. More about rewrite rules
        2. Patterns
        3. Captures and positional parameters
        4. Other functionalities of the rewrite engine
        5. Assigning variables
        6. Evaluating predicates using if sections
        7. Replying with a specified HTTP status code
      2. Access control
        1. Restricting access by IP address
        2. Using the geo directive to restrict access by IP address
        3. Using basic authentication for access restriction
        4. Authenticating users with a subrequest
        5. Combining multiple access restriction methods
      3. Summary
    12. 5. Managing Inbound and Outbound Traffic
      1. Managing inbound traffic
        1. Limiting the request rate
        2. Limiting the number of simultaneous connections
        3. Limiting the transfer rate of a connection
        4. Applying multiple limitations
      2. Managing outbound traffic
        1. Declaring upstream servers
        2. Using upstream servers
        3. Choosing a request distribution strategy
        4. Configuring backup servers
        5. Determining whether a server is available
        6. Enabling persistent connections
        7. Limiting the transfer rate of an upstream connection
      3. Summary
    13. 6. Performance Tuning
      1. Optimizing static file retrieval
      2. Enabling response compression
      3. Optimizing buffer allocation
      4. Enabling SSL session reuse
      5. Worker processes allocation on multi-core systems
      6. Summary
    14. Index

Product information

  • Title: Nginx Essentials
  • Author(s): Valery Kholodkov
  • Release date: July 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781785289538