Nginx HTTP Server


There is a newer version of this book available - Nginx HTTP Server - Second Edition
Nginx HTTP Server
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Get started with Nginx to serve websites faster and safer
  • Learn to configure your servers and virtual hosts efficiently
  • Set up Nginx to work with PHP and other applications via FastCGI
  • Explore possible interactions between Nginx and Apache to get the best of both worlds
  • A step-by-step guide to switching from Apache to Nginx
  • Complete configuration directive and module reference

Book Details

Language : English
Paperback : 348 pages [ 235mm x 191mm ]
Release Date : July 2010
ISBN : 1849510865
ISBN 13 : 9781849510868
Author(s) : Clément Nedelcu
Topics and Technologies : All Books, Networking and Servers, Open Source


Table of Contents

Preface
Chapter 1: Preparing your Work Environment
Chapter 2: Downloading and Installing Nginx
Chapter 3: Basic Nginx Configuration
Chapter 4: HTTP Configuration
Chapter 5: Module Configuration
Chapter 6: PHP and Python with Nginx
Chapter 7: Apache and Nginx Together
Chapter 8: From Apache to Nginx
Appendix A: Directive Index
Appendix B: Module Reference
Appendix C: Troubleshooting
Index
  • Chapter 1: Preparing your Work Environment
    • Setting up a terminal emulator
      • Finding and downloading PuTTY
      • Creating a session
      • Working with PuTTY and the shell
    • Basic shell commands
      • File and directory management
      • User and group management
        • Superuser account
        • User accounts
        • Group management
      • Programs and processes
        • Starting an application
        • System services
        • Process management
    • Discovering the Linux filesystem
      • Directory structure
      • Special files and devices
        • Device types
        • Pseudo devices
        • Mounting a storage device
      • Files and inodes
        • EXT3 filesystem specifications
        • Filenames
        • Inodes
        • Atime, ctime, and mtime
        • Symbolic and hard links
      • File manipulation
        • Reading a file
        • Editing a file
        • Compression and archiving
    • System administration tools
      • Running a command as Superuser
        • Su command
        • Sudo command
      • System verification and maintenance
        • Disk Free
        • Disk Usage
        • Free memory
      • Software packages
        • Package managers
        • Downloading and installing packages manually
        • Building from source
      • Files and permissions
        • Understanding file permissions
        • Directory permissions
        • Octal representation
        • Changing permissions
        • Changing ownership and group
    • Summary
  • Chapter 2: Downloading and Installing Nginx
    • Setting up the prerequisites
      • GCC — GNU Compiler Collection
      • PCRE library
      • zlib library
      • OpenSSL
    • Downloading Nginx
      • Websites and resources
      • Version branches
      • Features
      • Downloading and extracting
    • Configure options
      • The easy way
      • Path options
      • Prerequisites options
      • Module options
        • Modules enabled by default
        • Modules disabled by default
      • Miscellaneous options
      • Configuration examples
        • About the prefix switch
        • Regular HTTP and HTTPS servers
        • All modules enabled
        • Mail server proxy
      • Build configuration issues
        • Make sure you installed the prerequisites
        • Directories exist and are writable
      • Compiling and installing
    • Controlling the Nginx service
      • Daemons and services
      • User and group
      • Nginx command-line switches
      • Starting and stopping the daemon
      • Testing the configuration
      • Other switches
    • Adding Nginx as a system service
      • System V scripts
      • What is an init script?
      • Creating an init script for Nginx
      • Installing the script
        • Debian-based distributions
        • Red Hat-based distributions
    • Summary
  • Chapter 3: Basic Nginx Configuration
    • Configuration file syntax
      • Configuration Directives
      • Organization and inclusions
      • Directive blocks
      • Advanced language rules
        • Directives accept specific syntaxes
        • Diminutives in directive values
        • Variables
        • String values
    • Base module directives
      • What are base modules?
      • Nginx process architecture
      • Core module directives
      • Events module
      • Configuration module
    • A configuration for your profile
      • Understanding the default configuration
      • Necessary adjustments
      • Adapting to your hardware
    • Testing your server
      • Creating a test server
      • Performance tests
        • Httperf
        • Autobench
        • OpenWebLoad
      • Upgrading Nginx gracefully
    • Summary
  • Chapter 4: HTTP Configuration
    • HTTP Core module
      • Structure blocks
    • Module directives
      • Socket and host configuration
      • Paths and documents
      • Client requests
      • MIME Types
      • Limits and restrictions
      • File processing and caching
      • Other directives
    • Module variables
      • Request headers
      • Response headers
      • Nginx generated
    • The Location block
      • Location modifier
      • Search order and priority
        • Case 1:
        • Case 2:
        • Case 3:
    • Summary
  • Chapter 5: Module Configuration
    • Rewrite module
      • Reminder on regular expressions
        • Purpose
        • PCRE syntax
        • Quantifiers
        • Captures
      • Internal requests
        • error_page
        • Rewrite
        • Infinite loops
        • Server Side Includes (SSI)
      • Conditional structure
      • Directives
      • Common rewrite rules
        • Performing a search
        • User profile page
        • Multiple parameters
        • Wikipedia-like
        • News website article
        • Discussion board
    • SSI module
      • Module directives and variables
      • SSI Commands
        • File includes
        • Working with variables
        • Conditional structure
        • Configuration
    • Additional modules
      • Website access and logging
        • Index
        • Autoindex
        • Random index
        • Log
      • Limits and restrictions
        • Auth_basic module
        • Access
        • Limit zone
        • Limit request
      • Content and encoding
        • Empty GIF
        • FLV
        • HTTP headers
        • Addition
        • Substitution
        • Gzip filter
        • Gzip static
        • Charset filter
        • Memcached
        • Image filter
        • XSLT
      • About your visitors
        • Browser
        • Map
        • Geo
        • GeoIP
        • UserID filter
        • Referer
        • Real IP
      • SSL and security
        • SSL
        • Setting up an SSL certificate
        • Secure link
      • Other miscellaneous modules
        • Stub status
        • Google-perftools
        • WebDAV
      • Third-party modules
    • Summary
  • Chapter 6: PHP and Python with Nginx
    • Introduction to FastCGI
      • Understanding the mechanism
      • Common Gateway Interface (CGI)
      • Fast Common Gateway Interface (FastCGI)
      • Main directives
      • FastCGI caching
      • Upstream blocks
        • Module syntax
        • Server directive
    • PHP with Nginx
      • Architecture
      • PHP-FPM
      • Setting up PHP and PHP-FPM
        • Downloading and extracting
        • Patching
        • Requirements
        • Building PHP
        • Post-install configuration
        • Running and controlling
      • Nginx configuration
    • Python and Nginx
      • Django
      • Setting up Python and Django
        • Python
        • Django
        • Starting the FastCGI process manager
      • Nginx configuration
    • Summary
  • Chapter 7: Apache and Nginx Together
    • Nginx as reverse proxy
      • Understanding the issue
      • The reverse proxy mechanism
      • Advantages and disadvantages
    • Nginx Proxy module
      • Main directives
      • Caching, buffering, and temporary files
      • Limits, timeouts, and errors
      • Other directives
      • Variables
    • Configuring Apache and Nginx
      • Reconfiguring Apache
        • Configuration overview
        • Resetting the port number
        • Accepting local requests only
      • Configuring Nginx
        • Enabling proxy options
        • Separating content
      • Advanced configuration
    • Additional steps
      • Forwarding the correct IP address
      • SSL issues and solutions
      • Server control panel issues
    • Summary
  • Chapter 8: From Apache to Nginx
    • Nginx versus Apache
      • Features
        • Core and functioning
        • General functionality
      • Flexibility and community
      • Performance
      • Usage
      • Conclusion
    • Porting your Apache configuration
      • Directives
      • Modules
      • Virtual hosts and configuration sections
        • Configuration sections
        • Creating a virtual host
      • htaccess files
        • Reminder on Apache .htaccess files
        • Nginx equivalence
    • Rewrite rules
      • General remarks
        • On the location
        • On the syntax
        • RewriteRule
      • WordPress
      • MediaWiki
      • vBulletin
    • Summary
  • Appendix B: Module Reference
    • Access
    • Addition*
    • Auth_basic module
    • Autoindex
    • Browser
    • Charset
    • Core
    • DAV*
    • Empty GIF
    • Events
    • FastCGI
    • FLV*
    • Geo
    • Geo IP*
    • Google-perftools*
    • Gzip
    • Gzip Static*
    • Headers
    • HTTP Core
    • Image Filter*
    • Index
    • Limit Requests
    • Limit Zone
    • Log
    • Map
    • Memcached
    • Proxy
    • Random index*
    • Real IP*
    • Referer
    • Rewrite
    • Secure Link*
    • SSI
    • SSL*
    • Stub status*
    • Substitution*
    • Upstream
    • User ID
    • XSLT*
  • Appendix C: Troubleshooting
    • General tips on troubleshooting
      • Checking access permissions
      • Testing your configuration
      • Have you reloaded the service?
      • Checking logs
      • Install issues
      • 403 Forbidden custom error page
      • Location block priorities
      • If block issues
        • Inefficient statements
        • Unexpected behavior

Clément Nedelcu

Clément Nedelcu was born in France and studied in UK, French, and Chinese universities. After teaching computer science and programming in several eastern Chinese universities, he worked as a Technology Consultant in France, specializing in web and Microsoft .NET programming as well as Linux server administration. Since 2005, he has also been administering a major network of websites in his spare time. This eventually led him to discover Nginx: it made such a difference that he started his own blog about it. One thing leading to another…
Sorry, we don't have any reviews for this title yet.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 4 submitted: last submission 29 Aug 2013

Errata type: Technical | Page number: 114 (Page 131 when reading ebook)

Given sentence (at the bottom): "However, if Nginx receives a request for http://localhost/admin/, the path used to retrieve the files is /home/website.com/locked/."

Correct sentence: "However, if Nginx receives a request for http://localhost/admin/, the path used to retrieve the files is /var/www/locked/."

 

Errata type: Typo | Page number: 125

Correction: The directive type listed (the last directive from the bottom) should be directio and not direction.

 

Errata type: Technical | Page number: 119

Correction: In the section describing client_body_timeout, about halfway down page 119:

Default value: 60
    send_timeout 60;

should read:

Default value: 60
    client_body_timeout 60;

Errata type: Typo | Page number: 136

Correction: In the "Search order and priority" at the bottom of page 136, the line:

    location /files/ {"

should read

    location /files/ {

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Nginx HTTP Server +    Liferay Portal 6 Enterprise Intranets =
50% Off
the second eBook
Price for both: £23.45

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Download and build Nginx from source along with its dependencies
  • Learn the basics of Nginx configuration: syntax, structure, and semantics
  • Create virtual host configurations effortlessly
  • Discover how to enable, configure, and use all first-party modules
  • Establish advanced rewrite rules with the Nginx Rewrite module
  • Set up Nginx to work with PHP, Python, and more via FastCGI
  • Configure Nginx to work as frontend for your existing HTTP server
  • Complete the process of replacing Apache by Nginx
  • Follow three practical examples on how to port your Apache rewrite rules
  • Find your way through the configuration with the complete detailed directive reference
  • Troubleshooting: know where to start looking if something goes wrong

In Detail

Nginx is a lightweight HTTP server designed for high-traffic websites, with network scalability as primary objective. With the advent of high-speed Internet access, short loading times and fast transfer rates have become a necessity. This free open-source solution will either serve as full replacement of other software such as Apache, or stand in front of your existing infrastructure to improve its overall speed. However, migrating to Nginx requires some guidance.

This book serves as a detailed guide to setting up Nginx in different production situations: as standalone server, as reverse proxy, interacting with applications via FastCGI, and more. In addition, the complete directive reference will be your best friend at all stages of the configuration and maintenance processes.

This book is the perfect companion for both Nginx beginners and experienced administrators. For the former, it will take you through the complete process of setting up this lightweight HTTP server on your system and configuring its various modules to get it to do exactly what you need, in a fast and secure way. For the latter, it provides different angles of approach that can help you make the most of your current infrastructure. As the book progresses, it provides a complete reference to all the modules and directives of Nginx. It will explain how to replace your existing server with Nginx or configure Nginx to work as a frontend for your existing server.

By the end of this book, you will be geared up to implement Nginx as a web server that will boost the speed of all your web applications.

A handy guide to setting up Nginx as a standalone web server or as a reverse proxy, with complete directive and module references

Approach

The book includes detailed instructions for each of the processes it describes: downloading and installing the application, configuring and using modules, and much more. It provides a step-by-step tutorial to replace your existing web server with Nginx. With commented configuration sections and in-depth module descriptions, you will be able to make the most of the performance potential offered by Nginx.

Who this book is for

By covering both early setup stages and advanced topics, this book will suit web administrators interested in solutions to optimize their infrastructure, whether they are looking into replacing existing web server software or integrating a new tool cooperating with applications already up and running. If you, your visitors, and your operating system have been disappointed by Apache, this book is exactly what you need.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software