Mastering Nginx

(Ron) #1
Chapter 6

[ 121 ]


  • min_uses: The file descriptor has to
    be used this amount of times within
    the inactive period in order to
    remain open

  • valid: NGINX will check this
    often to see if the file descriptor still
    matches a file with the same name

  • off: Disables the cache


In the following example, log entries will be compressed at a gzip level of 4. The buffer
size is the default of 64 KB and will be flushed to disk at least every minute.


access_log /var/log/nginx/access.log.gz combined gzip=4 flush=1m;


Note that when specifying gzip the log_format parameter is not optional.


The default combined log_format is constructed like this:


log_format combined '$remote_addr - $remote_user [$time_local] '


'"$request" $status $body_bytes_sent '


'"$http_referer" "$http_user_agent"';


As you can see, line breaks may be used to improve readability. They do not affect


the log_format itself. Any variables may be used in the log_format directive. The
variables in the following table which are marked with an asterisk (*) are specific to


logging and may only be used in the log_format directive. The others may be used


elsewhere in the configuration, as well.


Table: Log format variables

Variable Name Value
$body_bytes_sent The number of bytes sent to the client,
excluding the response header.
$bytes_sent The number of bytes sent to the client.
$connection A serial number, used to identify unique
connections.
$connection_requests The number of requests made through a
particular connection.
$msec The time in seconds, with millisecond
resolution.
$pipe * Indicates if the request was pipelined (p)
or not (.).
Free download pdf