Book Image

Nginx Module Extension

By : Usama Dar
Book Image

Nginx Module Extension

By: Usama Dar

Overview of this book

<p>Companies can solve significant scaling issues thanks to switching their web platforms to Nginx. A popular web server for building web infrastructure, Nginx transparently and effectively enables the growth of the largest sites on the Internet today, on top of being free and open source.</p> <p>This book is a practical reference providing you with everything you need to know about Nginx module extensions. You will learn how to write powerful and flexible configuration files and your own modules, as well as gaining knowledge about Nginx’s modular architecture, available modules, and their intricate details.</p> <p>Nginx Module Extension starts by teaching you to compile the Nginx source on multiple platforms. Then you will learn the synopsis, directives, and practical examples of the core, optional, and third party Nginx modules before familiarizing yourself with Nginx internals, enabling you to write custom modules.</p> <p>You will learn about the flexibility of the Nginx configuration and how to enable and disable various options while building from the source. You will learn to customize the Main and Events module to fine-tune the web server performance, and you will also learn about standard and optional HTTP modules like GeoIP, Gzip, Access Control, and using SSL, along with an exploration of PostgreSQL, MySQL, and Memcached modules. Finally you will learn internals like module chaining and will see sample code and a line-by-line walkthrough demonstrating how to write your own module.</p>
Table of Contents (12 chapters)

Preface

This book is for advanced users such as system administrators and developers who want to extend Nginx's functionality using its highly flexible add-on system. We look at the existing modules available and how to compile and install them, along with practical examples of how to configure them with focus on optimizing the configuration. It also goes beyond what is available off the shelf and teaches you how to write your own module, in case something is not available from the big Nginx open source community.

What this book covers

Chapter 1, Installing Nginx Core and Modules from Source, serves as a quick reference for downloading and installing Nginx and compilation options related to different modules and add-ons.

Chapter 2, Configuring Core Modules, is a reference to the core modules in Nginx, which cannot be disabled, and explores different configuration options for them.

Chapter 3, Installing and Configuring HTTP Modules, is a reference to the standard and optional HTTP modules, their synopsis, directives as well as practical configuration examples.

Chapter 4, Installing Third-party Modules, introduces third-party modules, mostly available on GitHub. It talks about some well-known third-party modules, their installation and configuration, and also some guidelines on how to find different third-party modules out there.

Chapter 5, Creating Your Own Module, gives a brief introduction to creating your own modules. This chapter is a quick reference to the module system in Nginx. It also has a quick reference to the internal architecture of Nginx, which makes extension possible.

What you need for this book

This book will help you understand the module-based architecture of Nginx. You will learn to install Nginx as well as extend it with several available modules. This book specially touches on the topic of creating your own Nginx modules. Most people have to read heaps of code to get this done. This book will make it easier for advanced users who are looking to extend Nginx by not only using existing modules, but also writing something of their own.

Who this book is for

This book is intended for advanced users, system administrators, and developers of Nginx modules.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can reload the Nginx configuration once you edit the nginx.conf file."

A block of code is set as follows:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

ngx_uint_t            spare0;
ngx_uint_t            spare1;
ngx_uint_t            spare2;
ngx_uint_t            spare3;

ngx_uint_t            version;
void                 *ctx;

Any command-line input or output is written as follows:

# cd /usr/ports/www/nginx
# make install clean

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: "For example, according to the following configuration, this module will make sure that it prints Hello World."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.