Mastering Nginx

(Ron) #1

A Configuration Guide


[ 30 ]

The virtual server section


Any context beginning with the keyword server is considered a "virtual server"


section. It describes a logical separation of a set of resources that will be delivered


under a different server_name directive. These virtual servers respond to HTTP
requests, and so are contained within the http section.


A virtual server is defined by a combination of the listen and server_name


directives. listen defines an IP address/port combination or path to a


UNIX-domain socket:


listen address[:port];
listen port;
listen unix:path;

The listen directive uniquely identifies a socket binding under NGINX.
There are also a number of optional parameters that listen can take:


Table: listen parameters

Parameter Explanation Comment
default_server Defines this
address:port
combination as being the
default for the requests
bound here.
setfib Sets the corresponding FIB
for the listening socket.

Only supported on FreeBSD.
Not for UNIX-domain
sockets.
backlog Sets the backlog parameter
in the listen() call.

Defaults to -1 on FreeBSD
and 511 on all other
platforms.
rcvbuf Sets the SO_RCVBUF
parameter on the listening
socket.
sndbuf Sets the SO_SNDBUF
parameter on the listening
socket.
accept_filter Sets the name of the accept
filter to either dataready
or httpready.

Only supported on FreeBSD.
Free download pdf