标签:
The following set of modules allows you to configure how visitors access your website and the way your server logs requests.
The Index module provides a simple directive named index, which lets you define the page that Nginx will serve by default if no filename is specified in the client request (in other words, it defines the website index page). You may specify multiple filenames; the first file to be found will be served. If none of the specified files are found, Nginx will either attempt to generate an automatic index of the files, if the autoindex directive is enabled, or return a 403 Forbidden error page.
Optionally, you may insert an absolute filename (such as /page.html) but only as the last argument of the directive.
Syntax: index file1 [file2…] [absolute_file];
Default value: index.html
Eaxmple:
index index.php index.html index.htm;
index index.php index2.php /catchall.php;
This directive is valid in the following contexts: http, server, location.
If Nginx cannot provide an index page for the requested directory, the default behavior is to return a 403 Forbidden HTTP error page. With the following set of directives, you enable an automatic listing of the files that are present in the requested directory:
Three columns of information appear for each file—the filename, the file date and time, and the file size in bytes.
Context: http, server, location
Enables or disables automatic directory listing for directories missing an index page.
Syntax: on or off
Context: http, server, location
If set to on, this directive ensures that the listing displays file sizes in bytes. Otherwise, another unit is employed, such as KB, MB, or GB.
Syntax: on or off
Default value: on
Context: http, server, location
By default, this directive is set to off, so the date and time of files in the listing appears as GMT time. Set it to on to make use of the local server time.
Syntax: on or off
Default value: off
This module enables a simple directive, random_index, which can be used within a location block in order for Nginx to return an index page selected randomly among the files of the specified directory.
This module is not included in the default Nginx build.
Syntax: on or off
This module controls the behavior of Nginx regarding access logs. It is a key module for system administrators as it allows analyzing the runtime behavior of web applications. It is composed of three essential directives:
Context: http, server, location
This parameter defines the access log file path, the format of entries in the access log by selecting a template name, or disables access logging.
Syntax: access_log path [format [buffer=size]] | off;
Some remarks concerning the directive syntax:
Context: http, server, location
Defines a template to be utilized by the access_log directive, describing the contents that should be included in an entry of
the access log.
Syntax: log_format template_name format_string;
The default template is called combined and matches the following example:
log_format combined ‘$remote_addr - $remote_user [$time_local] ‘"$request" $status $body_bytes_sent ‘"$http_referer" "$http_user_agent"‘;
# Other example
log_format simple ‘$remote_addr $request‘;
Context: http, server, location
Configures the cache for log file descriptors. Please refer to the open_file_cache directive of the HTTP Core Module for additional information.
Syntax: open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time] | off;
The arguments are similar to the open_file_cache and other related directives; the difference being that this applies to access log files only.
The Log module also enables several new variables, though they are only accessible when writing log entries:
Nginx - Additional Modules, Website Access and Logging
标签:
原文地址:http://www.cnblogs.com/huey/p/5769780.html