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)

Understanding the Events module


The Events module deals with the configuration of epoll, kqueue, select, poll, and more. This module consists of the following directives:

Name

Value

Default

Example

accept_mutex

on, off

on

off

accept_mutex_delay

interval (ms)

500ms

500ms

debug_connection

ip, cidr

none

192.168.1.1

devpoll_changes

number

32

64

devpoll_events

number

32

64

kqueue_changes

number

512

512

kqueue_events

number

512

512

epoll_events

number

512

512

multi_accept

on, off

off

on

rtsig_signo

signal number

SIGRTMIN+10

 

rtsig_overflow_events

number

16

24

rtsig_overflow_test

number

32

40

rtsig_overflow_threshold

number

10

3

use

Kqueue, rtsig, epoll, /dev/poll, select

decided by the configure script

rtsig

worker_connections

number

512

200

Explaining directives

We will now discuss the Events module's directives summarized in the preceding table, in detail.

accept_mutex

The accept_mutex directive tries to prevent workers...