Types |
HTTP, server, location |
Types {MIME type file suffix;}; |
Configures the types of files that can be processed. such as: text/html html htm shtml; |
Include |
Any |
Include file path; |
Copy the contents of the external file into the nginx.conf file as a configuration. Such as: include Mime.type; Copy the Mime.type configuration file from the current directory to the Nginx configuration file. The file path can be a relative path or an absolute path. The file name can be represented by a * wildcard character. |
Default_type |
HTTP, server, location |
Default_type MIME type; |
The mapping of file names to suffixes. Configures the default MIME type, using the type specified by Default_type when the requested file type is not found in the types Directive. The default is the Text/plain type. |
Access_log |
HTTP, server, location, if on location, limit_except |
Access_log path [format [buffer=size] [gzip[=level] [flush=time] [if=condition]]; Access_log off; |
Turn off or turn on access logging. The default configuration is: Access_log Logs/access.log combined; Represents the log format defined by combined, written to the Logs/access.log file, combined is the HTTP module default format. If one of the parameters of buffer and gzip is defined, the log is written to the cache by default, and when the cache is full, the logs in the cache are compressed by gzip and written to the file, gzip compression must be enabled to add the Gzip module when the Nginx is installed. The cache size defaults to 64K. The 1~9 compression level of gzip can be configured, the higher the compression efficiency, the smaller the log file occupies, but the higher the system performance is required. The default value is 1. Http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log |
log_format |
http |
log_format format name log format; |
defines the format of the HTTP access log, which allows access to the inline variables of the HTTP module in the log format. If it changes, it will be the log output. Example: r e m o T e a d d R , request, and more variables, see: Http://nginx.org/en/docs/http/ngx_http_core_module.html#variables |
Sendfile |
HTTP, server, location, if in location |
Sendfile on | Off |
Enable kernel copy mode. As a static server, you can increase the maximum IO access speed. Traditional file read and write using read and write mode, the process is: HDD >> kernel buffer >> user buffer>> kernel socket buffer >> protocol stack, The process of reading and writing with sendfile files is: HDD >> kernel buffer (fast copy to Kernelsocket buffer) >> protocol stack, Obviously sendfile this system call reduces the number of transitions and copies of data between kernel-to-user mode, directly copying the data from the kernel cache to the protocol stack, which improves efficiency. This article describes the comparative details: http://xiaorui.cc/?p=1673 |
Tcp_nodelay |
HTTP, server, location |
Off|on; |
|
Tcp_nopush |
HTTP, server, location |
Off|on; |
The two parameters, Tcp_nodelay and Tcp_nopush, are used together to start both configurations and send the data after the packet reaches a certain size. This reduces the number of network traffic, reduces the probability of blocking, but also affects the timeliness of response. Compare large data communication scenarios that are appropriate for file downloads. |
Keepalive_timeout |
HTTP, server, location |
Keepalive_time 65; |
The timeout of the client-to-server connection has been exceeded, and the server has been disconnected for more than the specified time. The default is 75 seconds. Reducing the alive time per connection can increase the number of responsive connections to some extent, so this value can generally be appropriately lowered |
Gzip |
HTTP, server, location, if in location |
gzip on | Off |
Turn on content compression to effectively reduce client access and network bandwidth |
Gzip_min_length |
HTTP, server, location |
Gzip_min_length length; |
The unit is k, which defaults to 20k. When the content exceeds the minimum length, the compression is turned on because too short content compression is poor and the compression process wastes system resources. This compression length is returned to the client as the HTTP response header content-length field. Recommended value: 1000 |
Gzip_comp_level |
HTTP, server, location |
Gzip_comp_level 1~9; |
The compression level, the default value is 1. Range is 1~9, the higher the compression level, the higher the compression rate, but the higher the system performance requirements. Recommended Value: 4 |
Gzip_types |
HTTP, server, location |
Gzip_types Mime-type ...; |
Compressed content type, default is text/html;. Only compressed HTML text, generally we will compress JS, CSS, JSON and so on, you can match these common text data. such as: Text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/ JavaScript |
Open_file_cache |
HTTP, server, location |
Open_file_cache off; Open_file_cache max=n [Inactive=time]; |
The default value is off; Sets the maximum number of caches, and the lifetime of the cache file that is not used. Recommended value: max=655350 (consistent with worker_rlimit_nofile parameters) inactive=20s; |
Open_file_ Cache_min_uses |
HTTP, server, location |
Open_file_cache_min_uses number; |
The default is 1, and the minimum number of times a file is in the validity period. Recommended Value: 2 |
Open_file _cache_valid |
HTTP, server, location |
Open_file_cache_valid time; |
The default is 60s, which verifies the cache validity interval. Indicates that every 60s checks the cached files, which files are not used more than 2 times within 20s, and are removed from the cache. The LRU algorithm is used. |
Server |
server {...} |
http |
The core configuration of the HTTP server, the virtual host for configuring the HTTP server, can be configured with multiple |
Listen |
Listen ip[: Port] |
Server |
Configure the IP address and port on which the virtual host listens, by default listening for native IP addresses and 80 or 8000 ports. If only IP is not set, port 80 is used by default. If only the port is set, no IP is set by default using native IP. For detailed configuration, please refer to: Http://nginx.org/en/docs/http/ngx_http_core_module.html#listen |
server_name |
server_name domain_name ...; |
Server |
To configure the domain name of the virtual host, you can specify multiple, separated by spaces. Default is empty |
CharSet |
HTTP, server, location, if in location |
CharSet CharSet | Off |
Set the request encoding, and the URL parameter garbled problem. |
Location |
Server, Location |
Location [= | ~ | ~* | ^~] URI {...} Location @name {...} |
An important configuration item in an HTTP request that configures the matching rules for the client Pull server URL address. Multiple matching rules can be configured |