Table of Contents

Nginx - HTTP Request Processing

About

How nginx process a HTTP request

Steps

Server

nginx first decides which server should process the request with:

One Host on one IP

The request’s header field “Host”. If its value does not match any server name, or the request does not contain this header field at all, then nginx will route the request to the default server for this port.

If requests without the “Host” header field should not be allowed, a server that just drops the requests can be defined:

server {
        listen      80;
        server_name "";
        return      444;
}

where: the code 444 is a special status nginx code that closes the connection.

One host multiple listen IP

Steps:

Example:

server {
    listen      192.168.1.1:80;
    server_name example.org www.example.org;
    ...
}

server {
    listen      192.168.1.2:80;
    server_name example.com www.example.com;
    ...
}

Location

After the server has been found, the second step is to find the location block.

The Location block processing follows the following algorithm;

Ref

Documentation / Reference