Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26277649
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: 系统运维

2010-06-22 15:56:08

fastcgi_buffers

syntax: fastcgi_buffers the_number is_size;

default: fastcgi_buffers 8 4k/8k;

context: http, server, location

This directive sets the number and the size of buffers, into which will be read the answer, obtained from the fastcgi server. By default, the size of one buffer is equal to the size of page. Depending on platform this is either 4K, 8K or 16K.

fastcgi_buffer_size

syntax: fastcgi_buffer_size the_size

default: fastcgi_buffer_size 4k/8k

context: http, server, location

This directive sets the buffersize, into which will be read the first part of the response, obtained from the fastcgi server.

In this part of response the small response-header is located, as a rule.

By default, the buffersize is equal to the size of one buffer in directive fastcgi_buffers; however, it is possible to set it to less.

fastcgi_cache

syntax: fastcgi_cache zone;

default: off

context: http, server, location

The directive specifies the area which actually is the share memory's name for caching. The same area can be used in several places.

fastcgi_cache_key

syntax: fastcgi_cache_key line ;

default: none

context: http, server, location

The directive sets the key for caching, for example:

  fastcgi_cache_key localhost:9000$request_uri;

fastcgi_cache_methods

syntax: fastcgi_cache_methods [GET HEAD POST];

default: fastcgi_cache_methods GET HEAD;

context: main,http,location

GET/HEAD is syntax sugar, i.e. you can not disable GET/HEAD even if you set just

  POST;

fastcgi_cache_min_uses

syntax: fastcgi_cache_min_uses n

default: fastcgi_cache_min_uses 1

context: http, server, location

TODO: Description.

fastcgi_cache_path

syntax: fastcgi_cache_path /path/to/cache [levels=m:n keys_zone=name:time inactive=time clean_time=time]

default: none

context: http

TODO: Description.

fastcgi_cache_use_stale

syntax: fastcgi_cache_use_stale [updating|error|timeout|invalid_header|http_500]

default: fastcgi_cache_use_stale off;

context: http, server, location

TODO: Description.

fastcgi_cache_valid

syntax: fastcgi_cache_valid [http_error_code|time]

default: none

context: http, server, location

TODO: Description.

fastcgi_index

syntax: fastcgi_index file

default: none

context: http, server, location

The name of the file which will be appended to the URI and stored in the variable $fastcgi_script_name if URI concludes with a slash.

fastcgi_hide_header

syntax: fastcgi_hide_header name

context: http, server, location

By default, Nginx does not pass headers "Status" and "X-Accel-..." from the FastCGI process back to the client. This directive can be used to hide other headers as well.

If the headers "Status" and "X-Accel-..." must be provided, then it is necessary to use directive fastcgi_pass_header to force them to be returned to the client.

fastcgi_ignore_client_abort

syntax: fastcgi_ignore_client_abort on|off

default: fastcgi_ignore_client_abort off

context: http, server, location

This directive determines if current request to the FastCGI-server must be aborted in case the client aborts the request to the server.

fastcgi_intercept_errors

syntax: fastcgi_intercept_errors on|off

default: fastcgi_intercept_errors off

context: http, server, location

This directive determines whether or not to transfer 4xx and 5xx errors back to the client or to allow Nginx to answer with directive error_page.

Note: You need to explicitly define the error_page handler for this for it to be useful. As Igor says, "nginx does not intercept an error if there is no custom handler for it it does not show its default pages. This allows to intercept some errors, while passing others as are."

fastcgi_max_temp_file_size

syntax: fastcgi_max_temp_file_size 0

default: ?

context: ?

This directive turns off fastcgi buffering according to the source code.

fastcgi_no_cache

syntax: fastcgi_no_cache variable1 variable2 ...

default: '

context: http, server, location

Specifies in what cases the cached responses will not be used, e.g.

  fastcgi_no_cache $cookie_nocache  $arg_nocache$arg_comment;
fastcgi_no_cache $http_pragma $http_authorization;

The expression is false if it is equal to the empty string or "0". For instance, in the above example, the cache will be bypassed if the cookie "nocache" is set in the request.

fastcgi_param

syntax: fastcgi_param parameter value

default: none

context: http, server, location

Directive assigns the parameter, which will be transferred to the FastCGI-server.

It is possible to use strings, variables and their combination as values. Directives not set are inherited from the outer level. Directives set in current level clear any previously defined directives for the current level.

Below is an example of the minimally necessary parameters for PHP:

    SCRIPT_FILENAME  /home/www/scripts/php$fastcgi_script_name;
QUERY_STRING $query_string;

Parameter SCRIPT_FILENAME is used by PHP for determining the name of script to execute, and QUERY_STRING contains the parameters of the request.

If dealing with POST requests, then the three additional parameters are necessary. Below is an example of the minimally necessary parameters for PHP:

    REQUEST_METHOD   $request_method;
CONTENT_TYPE $content_type;
CONTENT_LENGTH $content_length;

If PHP was compiled with --enable-force-cgi-redirect, then it is necessary to transfer parameter REDIRECT_STATUS with the value of "200":

    REDIRECT_STATUS  200;

fastcgi_pass

syntax: fastcgi_pass fastcgi-server

default: none

context: location, if in location

Directive assigns the port or socket on which the FastCGI-server is listening. Port can be indicated by itself or as an address and port, for example:

     localhost:9000;

using a Unix domain socket:

     unix:/tmp/fastcgi.socket;

You may also use an upstream block.

 backend  {
localhost:1234;
}
 
backend;

fastcgi_pass_header

syntax: fastcgi_pass_header name

context: http, server, location

fastcgi_read_timeout

syntax: fastcgi_read_timeout time

default: 60

context: http, server, location

Directive sets the amount of time for upstream to wait for a fastcgi process to send data. Change this directive if you have long running fastcgi processes that do not produce output until they have finished processing. If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate.

fastcgi_redirect_errors

syntax: fastcgi_redirect_errors on|off

Directive is renamed from fastcgi_intercept_errors.

Parameters, transferred to FastCGI-server.

The request headers are transferred to the FastCGI-server in the form of parameters. In the applications and the scripts run from the FastCGI-server, these parameters are usually accessible in the form of environment variables. For example, the header "User-agent" is transferred as parameter HTTP_USER_AGENT. Besides the headers of the HTTP request, it is possible to transfer arbitrary parameters with the aid of directive fastcgi_param.

fastcgi_split_path_info

syntax: fastcgi_split_path_info regex

context: location

version: >= 0.7.31

 ~ ^(.+\.php)(.*)$ {
...
^(.+\.php)(.*)$;
SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
PATH_INFO $fastcgi_path_info;
PATH_TRANSLATED $document_root$fastcgi_path_info;
...
}

fastcgi_store

syntax: fastcgi_store [on | off | path]

default: fastcgi_store off

context: http, server, location

This directive sets the path in which upstream files are stored. The parameter "on" preserves files in accordance with path specified in directives alias or root. The parameter "off" forbids storing. Furthermore, the name of the path can be clearly assigned with the aid of the line with the variables:

   /data/www$original_uri;

The time of modification for the file will be set to the date of "Last-Modified" header in the response. To be able to safe files in this directory it is necessary that the path is under the directory with temporary files, given by directive fastcgi_temp_path for the data location.

This directive can be used for creating the local copies for dynamic output of the backend which is not very often changed, for example:

 /images/ {
/data/www;
404 = /fetch$uri;
}
 
/fetch {
;
 
fastcgi://backend;
on;
:rw group:rw all:r;
/data/temp;
 
/data/www;
}

To be clear fastcgi_store is not a cache, it's rather mirror on demand.

fastcgi_store_access

syntax: fastcgi_store_access users:permissions [users:permission ...]

default: fastcgi_store_access user:rw

context: http, server, location

This directive assigns the permissions for the created files and directories, for example:

  :rw  group:rw  all:r;

If any rights for groups or all are assigned, then it is not necessary to assign rights for user:

  group:rw  all:r;

Variables

$fastcgi_script_name

This variable is equal to the URI request or, if if the URI concludes with a forward slash, then the URI request plus the name of the index file given by fastcgi_index. It is possible to use this variable in place of both SCRIPT_FILENAME and PATH_TRANSLATED, utilized, in particular, for determining the name of the script in PHP.

For example, for the request "/info/":

    .php;
SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;

SCRIPT_FILENAME would equal "/home/www/scripts/php/info/index.php".

阅读(959) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~