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 Main module


The Nginx Main module consists of the following configuration directives or commands:

Name

Value

Default

Example

daemon

on, off

on

 

master_process

on, off

on

 

timer_resolution

interval

0

100ms

pid

file

logs/nginx.pid

/var/log/nginx.pid

lock_file

file

logs/nginx.lock

/var/log/nginx.lock

worker_processes

number, auto

1

2

debug_points

stop, abort

null

stop

user

user [group]

nobody nobody

www users

worker_priority

number

0

15

worker_cpu_affinity

cpu mask

 

0101 1010

worker_rlimit_nofile

number

 

1000

worker_rlimit_core

size

 

500M

worker_rlimit_sigpending

number

 

1000

working_directory

directory

compile time

/usr/local/nginx

env

variable = value

 

PERL5LIB=/data/site/modules

Explaining directives

We will now discuss all the Main module's directives mentioned in the preceding table in detail.

daemon

The daemon directive determines if Nginx will run in the daemon mode. A daemon (or a service) is a background...