Mastering Nginx

(Ron) #1
Chapter 6

[ 117 ]

The HTTP core module


The http module is NGINX's central module, which handles all interactions with


clients over HTTP. We have already discussed the following aspects of this module


in Chapter 2, A Configuration Guide:



  • Client directives

  • File I/O directives

  • Hash directives

  • Socket directives

  • The listen directive

  • Matching a request to a server_name and location directive


We will have a look at the remaining directives in the rest of this section, again divided


by type.


The server


The server directive starts a new context. We have already seen examples of its usage


throughout the book so far. One aspect that has not yet been examined in-depth is the
concept of a default server.


A default server in NGINX means that it is the first server defined in a particular


configuration with the same listen IP address and port as another server. A default


server may also be denoted by the default_server parameter to the listen directive.


The default server is useful to define a set of common directives that will then be
reused for subsequent servers listening on the same IP address and port:


server {

listen 127.0.0.1:80;

server_name default.example.com;

server_name_in_redirect on;

}

server {

listen 127.0.0.1:80;

server_name http://www.example.com;

}
Free download pdf