Book Image

Nginx Troubleshooting

By : Alexey Kapranov
Book Image

Nginx Troubleshooting

By: Alexey Kapranov

Overview of this book

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.
Table of Contents (15 chapters)
Nginx Troubleshooting
About the Author
About the Reviewers
Rare Nginx Error Messages

Replacing external redirects with internal ones

As modern frontend frameworks grow more and more complex, there is an alarming rise in the number of the so-called client-side redirects. Nginx has a great facility that will allow you to save some traffic and precious client waiting time on client redirects. First, let us briefly refresh your knowledge of those redirects.

All the HTTP responses are documents consisting of three principal parts:

  • There's the HTTP code (200: Ok, 404: Not found, and so on)

  • There are a number of loosely structured key-value pairs in the form of headers

  • There is a relatively large, opaque, optional body

There is a lot of good HTTP response codes documentation on the Internet (and also some hilarious pieces given at—the ones that are relevant to our discussion are in the fourth hundred, that is, between 300 and 399.

Responses with those codes are indications that a browser should immediately make another request instead of the original one....