Mastering Nginx

(Ron) #1
Chapter 2

[ 23 ]

Directive Explanation
use The use directive indicates which connection
processing method should be used. This will
overwrite the compiled-in default, and must
be contained in an events context, if used.
It will not normally need to be overridden,
except when the compiled-in default is found
to produce errors over time.
worker_connections This directive configures the maximum
number of simultaneous connections
that a worker process may have open.
This includes, but is not limited to, client
connections and connections to upstream
servers. This is especially important on
reverse proxy servers – some additional
tuning may be required at the operating
system level in order to reach this number
of simultaneous connections.

Here is a short example using each of these directives:


# we want nginx to run as user 'www'
user www;

# the load is CPU-bound and we have 12 cores
worker_processes 12;

# explicitly specifying the path to the mandatory error log
error_log /var/log/nginx/error.log;

# also explicitly specifying the path to the pid file
pid /var/run/nginx.pid;

# sets up a new configuration context for the 'events' module
events {

# we're on a Solaris-based system and have determined that nginx
# will stop responding to new requests over time with the default
# connection-processing mechanism, so we switch to the second-best
use /dev/poll;
Free download pdf