Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Nginx Troubleshooting
Nginx Troubleshooting

Nginx Troubleshooting: Investigate and solve problems with Nginx-powered websites using a deep understanding of the underlying principles

Arrow left icon
Profile Icon Alexey Kapranov
Arrow right icon
€19.99
eBook Apr 2016 172 pages 1st Edition
eBook
€19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Alexey Kapranov
Arrow right icon
€19.99
eBook Apr 2016 172 pages 1st Edition
eBook
€19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Nginx Troubleshooting

Chapter 2. Searching for Problems in Log Files

Nginx really is a breakthrough technology powering a great part of modern Web. And as with all great technologies, it stands on the shoulders of giants. Nginx would not be possible without Apache. One very important Unix tradition that Nginx embraces fully is thorough logging.

Logs are what you turn to the moment there is a problem with your Nginx instance. For a daemon, there are not really many ways to communicate its state to the administrator in a simple, reliable, and guaranteed to work way other than logs.

You will find the following topics in this chapter:

  • A comprehensive description of how Nginx logging is configured and what mistakes could be made in the configuration
  • A special section on how to log POST request bodies
  • A section on how log rotation works and why there is some potential for problems
  • A series of real-life error records from logs with analysis

Configuring Nginx logging

There are two types of logs that Nginx may write. One could also say that there are infinite types because of the log_format directive that allows you to create your own types of logs.

To refresh your memory about what directives are used to configure Nginx logging, here they are:

  • The error_log directive configures the logging of exceptional events that the developers of Nginx consider worth noting. Usually, this is all kinds of errors.

    The format of the directive is this:

    error_log <destination> <log level>;

    Note

    The first parameter is usually a path to the file with the log. Recent versions of Nginx starting with 1.7.1 also support logging via syslog, to a local or remote syslog server. There is also a rarely used misnamed special value stderr, which, by the way, does not redirect logging to stderr (the third standard stdio stream or &2 in shell terms) because it does not make much sense to log to stderr from a daemon—daemonization involves...

Creating infrastructure around logs

Okay, let's do some arithmetic. Suppose that you have a rather popular but not on a world scale (yet) website with about 50,000 visits per day. This is a number that managers brag about during their meetups; they get it from some analytics software. It almost means nothing regarding your job. Because what is a visit? Let's say that what you have is an e-commerce site; you sell some nonseasonal stuff, for example, power tools. Your average visitor will look at one to two pages with spikes to early tens when actually choosing and buying something. Let it be three pages per visit on average. What is a page? For you, it is a series of HTTP responses—the main document and all the embedded objects. People notoriously underestimate the sheer size of modern web pages. It would be a safe bet to say that your pages include on average 100 objects (HTML documents, images, scripts, style sheets, and so on) amounting to the size of over a megabyte...

Summary

In this chapter, we refreshed our knowledge of how logging works in Nginx. There are two types of logs; one of them may be infinitely extended, whereas the other is hard to parse by scripts because it does not have enough structure.

We spent some time on special topics, such as log rotation and logging POST request bodies (with a small test stand that we created step by step in the chapter, no less).

We also analyzed several error records from some real error logs.

The next chapter will have more actual problems analyzed and troubleshot. We will present several cases of actual problems that people had with read Nginx installations and try to debug them from the ground up.

Left arrow icon Right arrow icon

Key benefits

  • • Solve problems with your Nginx-powered websites before your audience notices anything
  • • Peek into the Nginx architecture and gain knowledge that will help you be valuable to you in the long run
  • • Gain knowledge of different types of problems in a step-by-step way

Description

Nginx is clearly winning the race to be the dominant software to power modern websites. It is fast and open source, maintained with passion by a brilliant team. This book will help you maintain your Nginx instances in a healthy and predictable state. It will lead you through all the types of problems you might encounter as a web administrator, with a special focus on performance and migration from older software. You will learn how to write good configuration files and will get good insights into Nginx logs. It will provide you solutions to problems such as missing or broken functionality and also show you how to tackle performance issues with the Nginx server. A special chapter is devoted to the art of prevention, that is, monitoring and alerting services you may use to detect problems before they manifest themselves on a big scale. The books ends with a reference to error and warning messages Nginx could emit to help you during incident investigations.

Who is this book for?

The book is for technical specialists who already use Nginx to serve web pages for their users. Whether you are an experienced system administrator or a new professional, this book will help you do your job in the most efficient way.

What you will learn

  • • Detect and investigate problems with your web servers
  • • Create correct and professional configuration files
  • • Get an in-depth understanding of the web server software
  • • Interpret Nginx log files easily and with actionable insights
  • • Make your websites respond as fast as possible
  • • Prevent problems by setting up proper monitoring and alerts

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 22, 2016
Length: 172 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281792
Vendor :
Nginx
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Apr 22, 2016
Length: 172 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281792
Vendor :
Nginx
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Mastering NGINX
€41.99
Nginx Troubleshooting
€24.99
NGINX Cookbook
€36.99
Total 103.97 Stars icon

Table of Contents

9 Chapters
1. Searching for Problems in Nginx Configuration Chevron down icon Chevron up icon
2. Searching for Problems in Log Files Chevron down icon Chevron up icon
3. Troubleshooting Functionality Chevron down icon Chevron up icon
4. Optimizing Website Performance Chevron down icon Chevron up icon
5. Troubleshooting Rare Specific Problems Chevron down icon Chevron up icon
6. Monitoring Nginx Chevron down icon Chevron up icon
7. Going Forward with Nginx Chevron down icon Chevron up icon
A. Rare Nginx Error Messages Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.