Nginx中http_fastcgi_module的配置

1、fastcgi_bind

Syntax: fastcgi_bind address [transparent] | off;
Default: —
Context: http, server, location
指令在调用connect()函数之前将解析每个上游socket到一个本地地址,可以使用在主机拥有多个网卡接口或别名,但是你只允许到外的连接来自指定的网卡或者地址的情况下。

2、
fastcgi_buffering
fastcgi_buffer_size
fastcgi_buffers
fastcgi_busy_buffers_size

Syntax: fastcgi_buffering on | off;
Default: fastcgi_buffering on;
Context: http, server, location
开启/关闭 buffering of responses from the FastCGI server.

开启时,通过使用fastcgi_buffer_size和fastcgi_buffers的配置,使用内存缓存整个response from 
fastcgi ,如果一个响应的大小超过限制内存缓存的大小,a part of the response将写入临时目录,此时由fastcgi_max_temp_file_size 和 fastcgi_temp_file_write_size 控制。

关闭时,nginx将不会缓存整个response from fastcgi,从fastcgi收到数据后,及时发送给客户端。但此时也需要设置fastcgi_buffer_size(此时可以理解为缓冲区的作用)

关闭时,对CPU的要求较高,开启时,需要较大的内存。


Syntax: fastcgi_buffer_size size;
Default: fastcgi_buffer_size 4k|8k;
Context: http, server, location
#the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform.

Syntax: fastcgi_buffers number size;
Default: fastcgi_buffers 8 4k|8k;
Context: http, server, location
#Sets the number and size of the buffers used for reading a response from the FastCGI server, for a single connection. By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform.


Syntax: fastcgi_busy_buffers_size size;
Default: fastcgi_busy_buffers_size 8k|16k;
Context: http, server, location
#一般设置为fastcgi_buffer_size的两倍.

3、

fastcgi_temp_path
fastcgi_temp_file_write_size
fastcgi_max_temp_file_size

Syntax: fastcgi_temp_path path [level1 [level2 [level3]]];
Default: fastcgi_temp_path fastcgi_temp;
Context: http, server, location
用法同client_body_temp_path
例如:
fastcgi_temp_path /opt/nginx/fastcgi_temp 1 2; //数字2表示目录名的字符数.
如果新上传的HTTP 包体使用00000123456作为临时文件名,就会被存放在这个目录中。
/opt/nginx/fastcgi_temp/6/45/00000123456

Syntax: fastcgi_temp_file_write_size size;
Default: fastcgi_temp_file_write_size 8k|16k;
Context: http, server, location
fastcgi 响应的 response 超过 fastcig_temp_file_write_size 限制的大小,将启用临时目录缓存response,该值的设置和fastcgi_buffer_size、fastcgi_buffers、fastcgi_max_temp_file_size相关。应大于fastcig_buffer_size,小于fastcig_max_temp_file_size,可以理解为response优先使用内存buffer,如果超过限制,才使用临时目录缓存。


Syntax: fastcgi_max_temp_file_size size;
Default: fastcgi_max_temp_file_size 1024m;
Context: http, server, location
该值的设置应大于fastcgi_temp_file_write_size。

4、
fastcgi_store
fastcgi_store_access

Syntax: fastcgi_store on | off | string;
Default: fastcgi_store off;
Context: http, server, location
用法同 proxy_store

Syntax: fastcgi_store_access users:permissions ...;
Default: fastcgi_store_access user:rw;
Context: http, server, location
用法同 proxy_store_access

5、fastcgi_split_path_info

 Syntax: fastcgi_split_path_info regex;
Default: —
Context: location
通过正则,获取pathinfo信息
例子:
location ~ ^(.+\.php)(.*)$ {
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
}

6、
fastcgi_send_timeout
fastcgi_read_timeout

Syntax: fastcgi_send_timeout time;
Default: fastcgi_send_timeout 60s;
Context: http, server, location
如果在这个时间内,Nginx没有发送数据到fastcgi server,则connect中断。这个事件并不是request的传输超时时间。

Syntax: fastcgi_read_timeout time;
Default: fastcgi_read_timeout 60s;
Context: http, server, location 
如果在这个时间内,Nginx没有收到fastcgi server的数据,则connect中断。这个事件并不是response的传输超时时间。

7、fastcgi_request_buffering

Syntax: fastcgi_request_buffering on | off;
Default: fastcgi_request_buffering on;
Context: http, server, location
开启时,Nginx读取完整的客户端请求后,才发送给fastcgi。
关闭时,Nginx收到客户端请求后,立即发送给fastcgi,增加cpu的开销.

8、
fastcgi_pass_request_body 
fastcgi_pass_request_headers
fastcgi_pass_header

Syntax: fastcgi_pass_request_body on | off;
Default: fastcgi_pass_request_body on;
Context: http, server, location
将客户端的所有请求体传送给fastcgi server.

Syntax: fastcgi_pass_request_headers on | off;
Default: fastcgi_pass_request_headers on;
Context: http, server, location
将客户端的所有请求体头部送给fastcgi server.

Syntax: fastcgi_pass_header field;
Default: —
Context: http, server, location
允许某一些头部信息,传送给fastcgi server

9、

fastcgi_cache
fastcgi_no_cache
fastcgi_cache_bypass
fastcgi_cache_key
fastcgi_cache_lock
fastcgi_cache_lock_age
fastcgi_cache_lock_timeout
fastcgi_cache_methods
fastcgi_cache_min_uses
fastcgi_cache_path
fastcgi_cache_purge
fastcgi_cache_revalidate
fastcgi_cache_use_stale
fastcgi_cache_valid
fastcgi_catch_stderr

相关文章:

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>