![]()
Table of Contents
Nginx Troubleshooting
Credits
About the Author
About the Reviewers
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Searching for Problems in Nginx Configuration
Introducing basic configuration syntax, directives, and testing
Simple directives
Multiline directives
Include directive
Testing Nginx configuration
The default configuration directory layout
A quick example of modifying the MIME types registry
Default nginx.conf
The http directive
Common mistakes in configuration
Semicolons and newlines
File permissions
Variables
Regular expressions
Summary
2. Searching for Problems in Log Files
Configuring Nginx logging
Logging POST requests
Conditional logging
Logging big request bodies
Creating infrastructure around logs
Configuring log rotation
Working with a lot of log data
Reading logs
Error log record
Summary
3. Troubleshooting Functionality
Processing a complain
Rolling back
Keeping Nginx configuration under source control
Keeping a case journal
Performing the simplest test
Performing the Internet connection test
Testing the general HTTP response traffic
Detecting a lying application
Working around an integration failure
The try_files directive
Setting up automatic removal from upstream
Configuring the good old SSI
Planning for more complete monitoring
Processing a situation of no traffic
Restarting Nginx properly
Investigating lower than usual traffic
Summary
4. Optimizing Website Performance
Why Nginx is so fast?
Optimizing individual upstreams
Optimizing static files
Optimizing PHP backends
Java backends
Optimizing Python and Ruby backends
Optimizing Perl backends
Using thread pools in Nginx
The caching layer of Nginx
Emitting caching headers
Caching in Nginx upstream modules
Caching static files
Replacing external redirects with internal ones
Summary
5. Troubleshooting Rare Specific Problems
Security warnings
Domain name mismatch
Expired certificates
Insecure warnings for valid certificates
The mixed – content warning
Building a secure proxy for the external content
Solving problems with cache
Obsolete pages and VirtualBox
Apache migration problems
Solving problems with WebSockets
Showing a file upload progress bar
Solving the problem of an idle upstream
Summary
6. Monitoring Nginx
Using ngxtop
Getting statistics from http_stub_status
Monitoring Nginx with Munin
Configuring alerts
Getting more status data from Nginx
Using Nginx Plus alternatives
nginx-module-vts
Luameter
nginx-lua-stats
The upsteam_check module in tengine
The requests/sec patch by Catap
The Ustats module
Summary
7. Going Forward with Nginx
System administration
Linux/Unix operating system as a whole
Modern Internet protocols
Specific backend software used in your company
Modern cloud platforms
Automation
Software development
Summary
A. Rare Nginx Error Messages
Index
![]()
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: April 2016
Production reference: 1190416
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-865-4
www.packtpub.com
![]()
Author
Alex Kapranoff
Reviewers
Titouan Galopin
Valery Kholodkov
Commissioning Editor
Dipika Gaonkar
Acquisition Editor
Reshma Raman
Content Development Editor
Sanjeet Rao
Technical Editor
Mohit Hassija
Copy Editor
Dipti Mankame
Project Coordinator
Judie Jose
Proofreader
Safis Editing
Indexer
Priya Sane
Graphics
Kirk D'Penha
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
![]()
Alex Kapranoff is an established IT professional with more than 20 years of experience in roles ranging from a database developer to the CTO of a social search engine start-up to an infrastructure manager of a huge web application with hundreds of millions of users. His background allows him to be more on the developer side of things, and he is happy to share some of that perspective with fellow system administration specialists.
![]()
Titouan Galopin is a certified PHP/Symfony French web architect from Paris. He currently works for SensioLabs, the company behind the PHP framework Symfony, and he has worked for various other companies, including LIIP, Emakina, Ademis, and Coburo.
Titouan graduated in computer science and information technology from the Paris-Saclay University, and he is currently pursuing an engineering degree at the University of Technology of Compiègne.
First as a web developer and then as a web architect since 2012, Titouan has worked on Nginx intensively for PHP applications and Dockerized environments. Within the few years of his work, he has accumulated a lot of experience with Nginx and shares his experience in this book and in the related one, Nginx High Performance, Packt Publishing.
Valery Kholodkov is a seasoned IT professional with a decade of experience in creating, building, scaling, and maintaining industrial-grade web services, web applications, and mobile application backends. Throughout his career, he has worked for well-known brands such as Yandex, Booking.com, and AVG. He currently works as the CTO of QubiQ Digital, a consumer acquisition agency. Valery has a deep understanding of technology, and he is able to express its essence, advantages, and risks to a layman, which makes him an accomplished author and technical reviewer.
![]()
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at
www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
<[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
- Fully searchable across every book published by Packt
- Copy and paste, print, and bookmark content
- On demand and accessible via a web browser
![]()
You will learn how to notes problems before your boss calls you about some pages not loading. You will learn how to find those problems using logs and your usual Linux toolbox. You will also learn how to minimize the probability of problems happening again.
Nginx started as a web acceler...