February 2018
Beginner to intermediate
348 pages
9h 40m
English
Modules also provide variables that can be used in the definition of directive values. For example, the Nginx HTTP core module defines the $nginx_version variable. Variables in Nginx always start with $—the dollar sign. When setting the log_format directive, you may include all kinds of variables in the format string:
[...]
location ^~ /admin/ {
access_log logs/main.log;
log_format main '$pid - $nginx_version - $remote_addr';
}
[...]
Some directives do not allow you to use variables:
error_log logs/error-$nginx_version.log;
The preceding directive is valid, syntax-wise. However, it simply generates a file named error-$nginx_version.log, without parsing the variable.
Read now
Unlock full access