Book Review: Nginx HTTP Server

folder_openNginx, Technology
commentNo Comments


I have to admit up front that I know the author of this book and originally introduced him to nginx, that said, the friendship between us will not affect this review.


I always skip to this part when I read reviews, so I figure I might as well start with it, the details will follow after the conclusion.

Nginx HTTP Server is a new book by Clément Nedelcu and published by Packt Publishing, it’s the first English book about nginx to be available for purchase. Previously users had to depend on the wiki and various blogs for documentation; before that IRC and the mailing list. All aspects of nginx have undergone huge growth, from the feature set to the user base and finally to the documentation. This book fills an important area in nginx documentation that has been missing, a hard copy of coherent logical steps that documents the nginx HTTP server. The wiki is a great source of information, but it’s difficult to print out easily readable material to bring on the train or bus to work, or even if you just want to sit down with a cup of tea and read.

Overall the book does what it promises, namely takes you from a person who’s never touched nginx to a person well versed in how to configure nginx. It does this while teaching you how to keep your configuration file readable and without clutter. Many people underestimate just how much the configuration file matters and then spend hours trying to figure out why nginx is doing something they don’t want it to.

The range of nginx related topics covered is extensive, covering both nginx by itself but also how nginx can co-exist with Apache and even how to migrate from Apache to nginx. Discussions of back-ends covers PHP and Python, but since nginx uses communication protocols like FastCGI it ends up being valid for more than simply PHP, which is also mentioned.

There are a few slip-ups in the book concerning best practice, and a few typos in some of the directives used. In general it does not affect what you learn from the book but it might cause confusion if you’re copy-pasting content into your configuration file.

The language used is easy enough to follow. While there are some odd sentence structures and word choices which will make you scratch your head, it does not hinder the books ability to convey knowledge.

I have not found any glaring errors which are completely wrong, which is a bonus as there often seem to be confusion about some Nginx aspects, probably the most weird thing was the author calling nginx updates rare – which is odd considering a new release is typically out every two weeks or so, a hugely fast release cycle in the software world.

In the end the book is worth buying if you are used to learning from books or simply prefer a hard copy of the documentation. It makes learning about nginx easier than having to use the wiki as you do not have to figure out in what order to learn about next as well as contain more descriptive language and examples.

You can purchase the book and find a sample chapter over at the book’s Pack Publishing page.

Onwards to the gritty details then.


The very first thought you’ll have about the books is “Holy hell this book has a huge table of contents” – and you’ll be right. It has 9 pages to cover roughly 305 pages of content, as such the table of contents is also extremely detailed. Ironically I find this to make it difficult to get a good overview, for instance the table of contents contains these three entries: “Case 1”, “Case 2”, “Case 3”. Useful, right? That said, it’s mostly positive if only a little overdone.

The book starts out with an entire chapter on Linux, really basic usage like downloading PuTTY and basic shell commands. I suppose this is good for the Linux beginner, I’m not sure that is the primary audience of the book, though. Nginx is, and probably will remain for a good while, a book for system administrators who are seeking additional performance because Apache cannot keep up.

If you are new to Linux then you’ll probably find it a rather thorough overview of Linux commands, much more than you’ll actually need to use nginx, though, I still recommend you get an actual book on Linux as OS hardening and security practices aren’t covered.

A note on the PHP compile. The book patches the PHP source with PHP-FPM, this is no longer required as of PHP 5.3.3 as it is now included in the core distribution and as such you just need to compile with –enable-fpm flag.

The Nginx Stuff

With the Linux introduction done it’s time for installing nginx, the author chooses to do this by compiling from source – which will probably confuse experienced administrators as they tend to tout the various distribution repositories like yum and apt-get. Problem with this is that nginx is very often significantly outdated and finding repositories or PPAs which contain updated versions would be more work than simply compiling from source. Additionally nginx does not support dynamic linking of modules, so they have to be compiled in. A positive for the book, in my opinion, though many will argue that it’s not newbie friendly and using OS packages is better, in the end I suppose it’s a matter of what you’re used to. I tend to use my OS repository for anything that isn’t critical to my business, nginx and PHP are the two most important elements so I really prefer knowing exactly what’s going on and not depend on my OS to install things properly.

Finally nginx is installed and the book immediately follows with an introduction of the file structure and configuration format. This is not a thorough description of everything, but rather an overview of how the configuration file is structured and how each section is used. I thought this was great as it gives you an overview for what the various contexts means that will be described later on.

After this follows what is basically the wiki compiled into a list of directives grouped under their module and then sorted by when you should be reading about it. It makes sense to do it like this even if most of the information is nothing unique.

I feel like I need to point out just how much volume this part takes up. Nginx has a ton of modules and a ton of options and all of them are documented here, it might come across as a big reference list but you should at the very least skim all of it, it will give you an invaluable idea of how much is possible with nginx and make you use the right module for what you want to do. The PHP via FastCGI section is especially detailed and useful as it applies to all languages which uses FastCGI to communicate.

The next chapter is a discussion of Apache and nginx together as well as a documentation of the proxy module, it discusses both advantages and disadvantages of this setup. I feel there are two problems with this section, first of all it exaggerates the problems with proxying to Apache and heavily suggests ditching it entirely, it also neglects to explain why Apache has performance problems. these two issues actually tie together and could have used some more details, I’ll follow up with a blog post about why Apache is slow and why proxying to Apache is perfectly fine.

The rest of the chapter is detailed and covers all the essentials, so overall it’s a very positive addition to the book.

The final chapter is how to completely migrate from Apache and covers issue such as the difference between Apache and nginx in programming architecture as well as modules and which modules in nginx can replace the Apache modules. The section on .htaccess files and how to convert them is useful and brutally honest, the fact is that it’s not easy to convert them as nginx simply works differently. You can almost always do exactly what you want, it just has to be done differently.

A personal favourite is that shared hosting is mentioned specifically, often we get people in #nginx asking how to use nginx on their shared hosting servers. The fact is that they probably shouldn’t, and this book admits that.

The Bad Stuff

I suppose there will always be things in a book that simply doesn’t fit. The Linux section seems to be to be more suited for a dedicated book. Linux is a complex OS to manage and takes time and dedication to learn, while this book gives a surface knowledge that’s enough for nginx it fails to mention the depth of Linux. If you do get a server and don’t know Linux then get it managed! You will be thankful that someone experienced is keeping it updated and secure.

The section on the rewrite module contains an introduction to Perl Regular Expressions that’s rather superficial as well, it could have done with a recommendation of further reading if people wanted to get a more thorough knowledge of PCRE.

While the book mostly keeps to good practice there are times when it breaks these and does things like use root inside a location block for no good reason. This shouldn’t create too much confusion, but it might be a good idea to read my Nginx Primer and the wiki pitfalls page.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.