Mastering Nginx

(Ron) #1

The NGINX HTTP Server


[ 122 ]

Variable Name Value
$request_length * The length of the request, including the
HTTP method, URI, HTTP protocol,
header, and request body.
$request_time The request processing time, with
millisecond resolution, from the first byte
received from the client to the last byte
sent to the client.
$status The response status.
$time_iso8601 * Local time in ISO8601 format.
$time_local * Local time in common log format
(%d/%b/%Y:%H:%M:%S %z).

In this section, we have focused solely on access_log and how that can


be configured. You can also configure NGINX to log errors. The error_log
directive is described in Chapter 8, Troubleshooting.


Finding files


In order for NGINX to respond to a request, it passes it to a content handler,


determined by the configuration of the location directive. The unconditional content


handlers are tried first: perl, proxy_pass, flv, mp4, and so on. If none of these is a
match, the request is passed to one of the following, in order: random index, index,


autoindex, gzip_static, static. Requests with a trailing slash are handled by
one of the index handlers. If gzip is not activated, then the static module handles the


request. How these modules find the appropriate file or directory on the filesystem is


determined by a combination of certain directives. The root directive is best defined
in a default server directive, or at least outside of a specific location directive, so


that it will be valid for the whole server:


server {

root /home/customer/html;

location / {

index index.html index.htm;

}
Free download pdf