Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_scgi_module.xml @ 1189:f25d00109de0
Documented cache keys_zone memory estimates.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 15 May 2014 20:58:55 +0400 |
parents | f9c8336fe43c |
children | dd4cfc6ce770 |
rev | line source |
---|---|
1180 | 1 <?xml version="1.0"?> |
2 | |
3 <!-- | |
4 Copyright (C) Igor Sysoev | |
5 Copyright (C) Nginx, Inc. | |
6 --> | |
7 | |
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> | |
9 | |
10 <module name="Module ngx_http_scgi_module" | |
11 link="/en/docs/http/ngx_http_scgi_module.html" | |
12 lang="en" | |
1189
f25d00109de0
Documented cache keys_zone memory estimates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1185
diff
changeset
|
13 rev="2"> |
1180 | 14 |
15 <section id="summary"> | |
16 | |
17 <para> | |
18 The <literal>ngx_http_scgi_module</literal> module allows passing | |
19 requests to an SCGI server. | |
20 </para> | |
21 | |
22 </section> | |
23 | |
24 | |
25 <section id="example" name="Example Configuration"> | |
26 | |
27 <para> | |
28 <example> | |
29 location / { | |
30 include scgi_params; | |
31 scgi_pass localhost:9000; | |
32 } | |
33 </example> | |
34 </para> | |
35 | |
36 </section> | |
37 | |
38 | |
39 <section id="directives" name="Directives"> | |
40 | |
41 <directive name="scgi_bind"> | |
42 <syntax><value>address</value> | <literal>off</literal></syntax> | |
43 <default/> | |
44 <context>http</context> | |
45 <context>server</context> | |
46 <context>location</context> | |
47 | |
48 <para> | |
49 Makes outgoing connections to an SCGI server originate | |
50 from the specified local IP <value>address</value>. | |
51 Parameter value can contain variables (1.3.12). | |
52 The special value <literal>off</literal> (1.3.12) cancels the effect | |
53 of the <literal>scgi_bind</literal> directive | |
54 inherited from the previous configuration level, which allows the | |
55 system to auto-assign the local IP address. | |
56 </para> | |
57 | |
58 </directive> | |
59 | |
60 | |
61 <directive name="scgi_buffer_size"> | |
62 <syntax><value>size</value></syntax> | |
63 <default>4k|8k</default> | |
64 <context>http</context> | |
65 <context>server</context> | |
66 <context>location</context> | |
67 | |
68 <para> | |
69 Sets the <value>size</value> of the buffer used for reading the first part | |
70 of the response received from the SCGI server. | |
71 This part usually contains a small response header. | |
72 By default, the buffer size is equal to the size of one | |
73 buffer set by the <link id="scgi_buffers"/> directive. | |
74 It can be made smaller, however. | |
75 </para> | |
76 | |
77 </directive> | |
78 | |
79 | |
80 <directive name="scgi_buffering"> | |
81 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
82 <default>on</default> | |
83 <context>http</context> | |
84 <context>server</context> | |
85 <context>location</context> | |
86 | |
87 <para> | |
88 Enables or disables buffering of responses from the SCGI server. | |
89 </para> | |
90 | |
91 <para> | |
92 When buffering is enabled, nginx receives a response from the SCGI server | |
93 as soon as possible, saving it into the buffers set by the | |
94 <link id="scgi_buffer_size"/> and <link id="scgi_buffers"/> directives. | |
95 If the whole response does not fit into memory, a part of it can be saved | |
96 to a <link id="scgi_temp_path">temporary file</link> on the disk. | |
97 Writing to temporary files is controlled by the | |
98 <link id="scgi_max_temp_file_size"/> and | |
99 <link id="scgi_temp_file_write_size"/> directives. | |
100 </para> | |
101 | |
102 <para> | |
103 When buffering is disabled, the response is passed to a client synchronously, | |
104 immediately as it is received. | |
105 nginx will not try to read the whole response from the SCGI server. | |
106 The maximum size of the data that nginx can receive from the server | |
107 at a time is set by the <link id="scgi_buffer_size"/> directive. | |
108 </para> | |
109 | |
110 <para> | |
111 Buffering can also be enabled or disabled by passing | |
112 “<literal>yes</literal>” or “<literal>no</literal>” in the | |
113 <header>X-Accel-Buffering</header> response header field. | |
114 This capability can be disabled using the | |
115 <link id="scgi_ignore_headers"/> directive. | |
116 </para> | |
117 | |
118 </directive> | |
119 | |
120 | |
121 <directive name="scgi_buffers"> | |
122 <syntax><value>number</value> <value>size</value></syntax> | |
123 <default>8 4k|8k</default> | |
124 <context>http</context> | |
125 <context>server</context> | |
126 <context>location</context> | |
127 | |
128 <para> | |
129 Sets the <value>number</value> and <value>size</value> of the | |
130 buffers used for reading a response from the SCGI server, | |
131 for a single connection. | |
132 By default, the buffer size is equal to one memory page. | |
133 This is either 4K or 8K, depending on a platform. | |
134 </para> | |
135 | |
136 </directive> | |
137 | |
138 | |
139 <directive name="scgi_busy_buffers_size"> | |
140 <syntax><value>size</value></syntax> | |
141 <default>8k|16k</default> | |
142 <context>http</context> | |
143 <context>server</context> | |
144 <context>location</context> | |
145 | |
146 <para> | |
147 When <link id="scgi_buffering">buffering</link> of responses from the SCGI | |
148 server is enabled, limits the total <value>size</value> of buffers that | |
149 can be busy sending a response to the client while the response is not | |
150 yet fully read. | |
151 In the meantime, the rest of the buffers can be used for reading the response | |
152 and, if needed, buffering part of the response to a temporary file. | |
153 By default, <value>size</value> is limited by the size of two buffers set by the | |
154 <link id="scgi_buffer_size"/> and <link id="scgi_buffers"/> directives. | |
155 </para> | |
156 | |
157 </directive> | |
158 | |
159 | |
160 <directive name="scgi_cache"> | |
161 <syntax><value>zone</value> | <literal>off</literal></syntax> | |
162 <default>off</default> | |
163 <context>http</context> | |
164 <context>server</context> | |
165 <context>location</context> | |
166 | |
167 <para> | |
168 Defines a shared memory zone used for caching. | |
169 The same zone can be used in several places. | |
170 The <literal>off</literal> parameter disables caching inherited | |
171 from the previous configuration level. | |
172 </para> | |
173 | |
174 </directive> | |
175 | |
176 | |
177 <directive name="scgi_cache_bypass"> | |
178 <syntax><value>string</value> ...</syntax> | |
179 <default/> | |
180 <context>http</context> | |
181 <context>server</context> | |
182 <context>location</context> | |
183 | |
184 <para> | |
185 Defines conditions under which the response will not be taken from a cache. | |
186 If at least one value of the string parameters is not empty and is not | |
187 equal to “0” then the response will not be taken from the cache: | |
188 <example> | |
189 scgi_cache_bypass $cookie_nocache $arg_nocache$arg_comment; | |
190 scgi_cache_bypass $http_pragma $http_authorization; | |
191 </example> | |
192 Can be used along with the <link id="scgi_no_cache"/> directive. | |
193 </para> | |
194 | |
195 </directive> | |
196 | |
197 | |
198 <directive name="scgi_cache_key"> | |
199 <syntax><value>string</value></syntax> | |
200 <default/> | |
201 <context>http</context> | |
202 <context>server</context> | |
203 <context>location</context> | |
204 | |
205 <para> | |
206 Defines a key for caching, for example | |
207 <example> | |
208 scgi_cache_key localhost:9000$request_uri; | |
209 </example> | |
210 </para> | |
211 | |
212 </directive> | |
213 | |
214 | |
215 <directive name="scgi_cache_lock"> | |
216 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
217 <default>off</default> | |
218 <context>http</context> | |
219 <context>server</context> | |
220 <context>location</context> | |
221 <appeared-in>1.1.12</appeared-in> | |
222 | |
223 <para> | |
224 When enabled, only one request at a time will be allowed to populate | |
225 a new cache element identified according to the <link id="scgi_cache_key"/> | |
226 directive by passing a request to an SCGI server. | |
227 Other requests of the same cache element will either wait | |
228 for a response to appear in the cache or the cache lock for | |
229 this element to be released, up to the time set by the | |
230 <link id="scgi_cache_lock_timeout"/> directive. | |
231 </para> | |
232 | |
233 </directive> | |
234 | |
235 | |
236 <directive name="scgi_cache_lock_timeout"> | |
237 <syntax><value>time</value></syntax> | |
238 <default>5s</default> | |
239 <context>http</context> | |
240 <context>server</context> | |
241 <context>location</context> | |
242 <appeared-in>1.1.12</appeared-in> | |
243 | |
244 <para> | |
245 Sets a timeout for <link id="scgi_cache_lock"/>. | |
246 </para> | |
247 | |
248 </directive> | |
249 | |
250 | |
251 <directive name="scgi_cache_methods"> | |
252 <syntax> | |
253 <literal>GET</literal> | | |
254 <literal>HEAD</literal> | | |
255 <literal>POST</literal> | |
256 ...</syntax> | |
257 <default>GET HEAD</default> | |
258 <context>http</context> | |
259 <context>server</context> | |
260 <context>location</context> | |
261 | |
262 <para> | |
263 If the client request method is listed in this directive then | |
264 the response will be cached. | |
265 “<literal>GET</literal>” and “<literal>HEAD</literal>” methods are always | |
266 added to the list, though it is recommended to specify them explicitly. | |
267 See also the <link id="scgi_no_cache"/> directive. | |
268 </para> | |
269 | |
270 </directive> | |
271 | |
272 | |
273 <directive name="scgi_cache_min_uses"> | |
274 <syntax><value>number</value></syntax> | |
275 <default>1</default> | |
276 <context>http</context> | |
277 <context>server</context> | |
278 <context>location</context> | |
279 | |
280 <para> | |
281 Sets the <value>number</value> of requests after which the response | |
282 will be cached. | |
283 </para> | |
284 | |
285 </directive> | |
286 | |
287 | |
288 <directive name="scgi_cache_path"> | |
289 <syntax> | |
290 <value>path</value> | |
291 [<literal>levels</literal>=<value>levels</value>] | |
292 <literal>keys_zone</literal>=<value>name</value>:<value>size</value> | |
293 [<literal>inactive</literal>=<value>time</value>] | |
294 [<literal>max_size</literal>=<value>size</value>] | |
295 [<literal>loader_files</literal>=<value>number</value>] | |
296 [<literal>loader_sleep</literal>=<value>time</value>] | |
297 [<literal>loader_threshold</literal>=<value>time</value>]</syntax> | |
298 <default/> | |
299 <context>http</context> | |
300 | |
301 <para> | |
302 Sets the path and other parameters of a cache. | |
303 Cache data are stored in files. | |
304 Both the key and file name in a cache are a result of | |
305 applying the MD5 function to the proxied URL. | |
306 The <literal>levels</literal> parameter defines hierarchy levels of a cache. | |
307 For example, in the following configuration | |
308 <example> | |
309 scgi_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m; | |
310 </example> | |
311 file names in a cache will look like this: | |
312 <example> | |
313 /data/nginx/cache/<emphasis>c</emphasis>/<emphasis>29</emphasis>/b7f54b2df7773722d382f4809d650<emphasis>29c</emphasis> | |
314 </example> | |
315 </para> | |
316 | |
317 <para> | |
318 A cached response is first written to a temporary file, | |
319 and then the file is renamed. | |
320 Starting from version 0.8.9, temporary files and the cache can be put on | |
321 different file systems. | |
322 However, be aware that in this case a file is copied | |
323 across two file systems instead of the cheap renaming operation. | |
324 It is thus recommended that for any given location both cache and a directory | |
325 holding temporary files, set by the <link id="scgi_temp_path"/> directive, | |
326 are put on the same file system. | |
327 </para> | |
328 | |
329 <para> | |
330 In addition, all active keys and information about data are stored | |
331 in a shared memory zone, whose <value>name</value> and <value>size</value> | |
332 are configured by the <literal>keys_zone</literal> parameter. | |
1189
f25d00109de0
Documented cache keys_zone memory estimates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1185
diff
changeset
|
333 One megabyte zone can store about 8 thousand keys. |
f25d00109de0
Documented cache keys_zone memory estimates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1185
diff
changeset
|
334 </para> |
f25d00109de0
Documented cache keys_zone memory estimates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1185
diff
changeset
|
335 |
f25d00109de0
Documented cache keys_zone memory estimates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1185
diff
changeset
|
336 <para> |
1180 | 337 Cached data that are not accessed during the time specified by the |
338 <literal>inactive</literal> parameter get removed from the cache | |
339 regardless of their freshness. | |
340 By default, <literal>inactive</literal> is set to 10 minutes. | |
341 </para> | |
342 | |
343 <para> | |
344 The special “cache manager” process monitors the maximum cache size set | |
345 by the <literal>max_size</literal> parameter. | |
346 When this size is exceeded, it removes the least recently used data. | |
347 </para> | |
348 | |
349 <para> | |
350 A minute after the start the special “cache loader” process is activated. | |
351 It loads information about previously cached data stored on file system | |
352 into a cache zone. | |
353 The loading is done in iterations. | |
354 During one iteration no more than <literal>loader_files</literal> items | |
355 are loaded (by default, 100). | |
356 Besides, the duration of one iteration is limited by the | |
357 <literal>loader_threshold</literal> parameter (by default, 200 milliseconds). | |
358 Between iterations, a pause configured by the <literal>loader_sleep</literal> | |
359 parameter (by default, 50 milliseconds) is made. | |
360 </para> | |
361 | |
362 </directive> | |
363 | |
364 | |
365 <directive name="scgi_cache_purge"> | |
366 <syntax>string ...</syntax> | |
367 <default/> | |
368 <context>http</context> | |
369 <context>server</context> | |
370 <context>location</context> | |
371 <appeared-in>1.5.7</appeared-in> | |
372 | |
373 <para> | |
374 Defines conditions under which the request will be considered a cache | |
375 purge request. | |
376 If at least one value of the string parameters is not empty and is not equal | |
377 to “0” then the cache entry with a corresponding | |
378 <link id="scgi_cache_key">cache key</link> is removed. | |
379 The result of successful operation is indicated by returning | |
380 the <http-status code="204" text="No Content"/> response. | |
381 </para> | |
382 | |
383 <para> | |
384 If the <link id="scgi_cache_key">cache key</link> of a purge request ends | |
385 with an asterisk (“<literal>*</literal>”), all cache entries matching the | |
386 wildcard key will be removed from the cache. | |
387 </para> | |
388 | |
389 <para> | |
390 Example configuration: | |
391 <example> | |
392 scgi_cache_path /data/nginx/cache keys_zone=cache_zone:10m; | |
393 | |
394 map $request_method $purge_method { | |
395 PURGE 1; | |
396 default 0; | |
397 } | |
398 | |
399 server { | |
400 ... | |
401 location / { | |
1185
f9c8336fe43c
Aligned configuration examples with fastcgi/scgi_cache_purge.
Ruslan Ermilov <ru@nginx.com>
parents:
1184
diff
changeset
|
402 scgi_pass backend; |
f9c8336fe43c
Aligned configuration examples with fastcgi/scgi_cache_purge.
Ruslan Ermilov <ru@nginx.com>
parents:
1184
diff
changeset
|
403 scgi_cache cache_zone; |
f9c8336fe43c
Aligned configuration examples with fastcgi/scgi_cache_purge.
Ruslan Ermilov <ru@nginx.com>
parents:
1184
diff
changeset
|
404 scgi_cache_key $uri; |
1180 | 405 scgi_cache_purge $purge_method; |
406 } | |
407 } | |
408 </example> | |
409 <note> | |
410 This functionality is available as part of our | |
411 <commercial_version>commercial subscription</commercial_version>. | |
412 </note> | |
413 </para> | |
414 | |
415 </directive> | |
416 | |
417 | |
418 <directive name="scgi_cache_revalidate"> | |
419 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
420 <default>off</default> | |
421 <context>http</context> | |
422 <context>server</context> | |
423 <context>location</context> | |
424 <appeared-in>1.5.7</appeared-in> | |
425 | |
426 <para> | |
427 Enables revalidation of expired cache items using conditional requests with | |
428 the <header>If-Modified-Since</header> header field. | |
429 </para> | |
430 | |
431 </directive> | |
432 | |
433 | |
434 <directive name="scgi_cache_use_stale"> | |
435 <syntax> | |
436 <literal>error</literal> | | |
437 <literal>timeout</literal> | | |
438 <literal>invalid_header</literal> | | |
439 <literal>updating</literal> | | |
440 <literal>http_500</literal> | | |
441 <literal>http_503</literal> | | |
442 <literal>http_403</literal> | | |
443 <literal>http_404</literal> | | |
444 <literal>off</literal> | |
445 ...</syntax> | |
446 <default>off</default> | |
447 <context>http</context> | |
448 <context>server</context> | |
449 <context>location</context> | |
450 | |
451 <para> | |
452 Determines in which cases a stale cached response can be used | |
453 when an error occurs during communication with the SCGI server. | |
454 The directive’s parameters match the parameters of the | |
455 <link id="scgi_next_upstream"/> directive. | |
456 </para> | |
457 | |
458 <para> | |
459 Additionally, the <literal>updating</literal> parameter permits | |
460 using a stale cached response if it is currently being updated. | |
461 This allows minimizing the number of accesses to SCGI servers | |
462 when updating cached data. | |
463 </para> | |
464 | |
465 <para> | |
466 To minimize the number of accesses to SCGI servers when | |
467 populating a new cache element, the <link id="scgi_cache_lock"/> | |
468 directive can be used. | |
469 </para> | |
470 | |
471 </directive> | |
472 | |
473 | |
474 <directive name="scgi_cache_valid"> | |
475 <syntax>[<value>code</value> ...] <value>time</value></syntax> | |
476 <default/> | |
477 <context>http</context> | |
478 <context>server</context> | |
479 <context>location</context> | |
480 | |
481 <para> | |
482 Sets caching time for different response codes. | |
483 For example, the following directives | |
484 <example> | |
485 scgi_cache_valid 200 302 10m; | |
486 scgi_cache_valid 404 1m; | |
487 </example> | |
488 set 10 minutes of caching for responses with codes 200 and 302 | |
489 and 1 minute for responses with code 404. | |
490 </para> | |
491 | |
492 <para> | |
493 If only caching <value>time</value> is specified | |
494 <example> | |
495 scgi_cache_valid 5m; | |
496 </example> | |
497 then only 200, 301, and 302 responses are cached. | |
498 </para> | |
499 | |
500 <para> | |
501 In addition, the <literal>any</literal> parameter can be specified | |
502 to cache any responses: | |
503 <example> | |
504 scgi_cache_valid 200 302 10m; | |
505 scgi_cache_valid 301 1h; | |
506 scgi_cache_valid any 1m; | |
507 </example> | |
508 </para> | |
509 | |
510 <para> | |
511 Parameters of caching can also be set directly | |
512 in the response header. | |
513 This has higher priority than setting of caching time using the directive. | |
514 The <header>X-Accel-Expires</header> header field sets caching time of a | |
515 response in seconds. | |
516 The zero value disables caching for a response. | |
517 If the value starts with the <literal>@</literal> prefix, it sets an absolute | |
518 time in seconds since Epoch, up to which the response may be cached. | |
519 If the header does not include the <header>X-Accel-Expires</header> field, | |
520 parameters of caching may be set in the header fields | |
521 <header>Expires</header> or <header>Cache-Control</header>. | |
522 If the header includes the <header>Set-Cookie</header> field, such a | |
523 response will not be cached. | |
524 Processing of one or more of these response header fields can be disabled | |
525 using the <link id="scgi_ignore_headers"/> directive. | |
526 </para> | |
527 | |
528 </directive> | |
529 | |
530 | |
531 <directive name="scgi_connect_timeout"> | |
532 <syntax><value>time</value></syntax> | |
533 <default>60s</default> | |
534 <context>http</context> | |
535 <context>server</context> | |
536 <context>location</context> | |
537 | |
538 <para> | |
539 Defines a timeout for establishing a connection with an SCGI server. | |
540 It should be noted that this timeout cannot usually exceed 75 seconds. | |
541 </para> | |
542 | |
543 </directive> | |
544 | |
545 | |
546 <directive name="scgi_hide_header"> | |
547 <syntax><value>field</value></syntax> | |
548 <default/> | |
549 <context>http</context> | |
550 <context>server</context> | |
551 <context>location</context> | |
552 | |
553 <para> | |
554 By default, | |
555 nginx does not pass the header fields <header>Status</header> and | |
556 <header>X-Accel-...</header> from the response of an SCGI | |
557 server to a client. | |
558 The <literal>scgi_hide_header</literal> directive sets additional fields | |
559 that will not be passed. | |
560 If, on the contrary, the passing of fields needs to be permitted, | |
561 the <link id="scgi_pass_header"/> directive can be used. | |
562 </para> | |
563 | |
564 </directive> | |
565 | |
566 | |
567 <directive name="scgi_ignore_client_abort"> | |
568 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
569 <default>off</default> | |
570 <context>http</context> | |
571 <context>server</context> | |
572 <context>location</context> | |
573 | |
574 <para> | |
575 Determines whether the connection with an SCGI server should be | |
576 closed when a client closes the connection without waiting | |
577 for a response. | |
578 </para> | |
579 | |
580 </directive> | |
581 | |
582 | |
583 <directive name="scgi_ignore_headers"> | |
584 <syntax><value>field</value> ...</syntax> | |
585 <default/> | |
586 <context>http</context> | |
587 <context>server</context> | |
588 <context>location</context> | |
589 | |
590 <para> | |
591 Disables processing of certain response header fields from the SCGI server. | |
592 The following fields can be ignored: <header>X-Accel-Redirect</header>, | |
593 <header>X-Accel-Expires</header>, <header>X-Accel-Limit-Rate</header> (1.1.6), | |
594 <header>X-Accel-Buffering</header> (1.1.6), | |
595 <header>X-Accel-Charset</header> (1.1.6), <header>Expires</header>, | |
596 <header>Cache-Control</header>, and <header>Set-Cookie</header> (0.8.44). | |
597 </para> | |
598 | |
599 <para> | |
600 If not disabled, processing of these header fields has the following | |
601 effect: | |
602 <list type="bullet" compact="no"> | |
603 | |
604 <listitem> | |
605 <header>X-Accel-Expires</header>, <header>Expires</header>, | |
606 <header>Cache-Control</header>, and <header>Set-Cookie</header> | |
607 set the parameters of response <link id="scgi_cache_valid">caching</link>; | |
608 </listitem> | |
609 | |
610 <listitem> | |
611 <header>X-Accel-Redirect</header> performs an | |
612 <link doc="ngx_http_core_module.xml" id="internal">internal | |
613 redirect</link> to the specified URI; | |
614 </listitem> | |
615 | |
616 <listitem> | |
617 <header>X-Accel-Limit-Rate</header> sets the | |
618 <link doc="ngx_http_core_module.xml" id="limit_rate">rate | |
619 limit</link> for transmission of a response to a client; | |
620 </listitem> | |
621 | |
622 <listitem> | |
623 <header>X-Accel-Buffering</header> enables or disables | |
624 <link id="scgi_buffering">buffering</link> of a response; | |
625 </listitem> | |
626 | |
627 <listitem> | |
628 <header>X-Accel-Charset</header> sets the desired | |
629 <link doc="ngx_http_charset_module.xml" id="charset"/> | |
630 of a response. | |
631 </listitem> | |
632 | |
633 </list> | |
634 </para> | |
635 | |
636 </directive> | |
637 | |
638 | |
639 <directive name="scgi_intercept_errors"> | |
640 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
641 <default>off</default> | |
642 <context>http</context> | |
643 <context>server</context> | |
644 <context>location</context> | |
645 | |
646 <para> | |
647 Determines whether an SCGI server responses with codes greater than or equal | |
648 to 300 should be passed to a client or be redirected to nginx for processing | |
649 with the <link doc="ngx_http_core_module.xml" id="error_page"/> directive. | |
650 </para> | |
651 | |
652 </directive> | |
653 | |
654 | |
655 <directive name="scgi_max_temp_file_size"> | |
656 <syntax><value>size</value></syntax> | |
657 <default>1024m</default> | |
658 <context>http</context> | |
659 <context>server</context> | |
660 <context>location</context> | |
661 | |
662 <para> | |
663 When <link id="scgi_buffering">buffering</link> of responses from the SCGI | |
664 server is enabled, and the whole response does not fit into the buffers | |
665 set by the <link id="scgi_buffer_size"/> and <link id="scgi_buffers"/> | |
666 directives, a part of the response can be saved to a temporary file. | |
667 This directive sets the maximum <value>size</value> of the temporary file. | |
668 The size of data written to the temporary file at a time is set | |
669 by the <link id="scgi_temp_file_write_size"/> directive. | |
670 </para> | |
671 | |
672 <para> | |
673 The zero value disables buffering of responses to temporary files. | |
674 </para> | |
675 | |
676 </directive> | |
677 | |
678 | |
679 <directive name="scgi_next_upstream"> | |
680 <syntax> | |
681 <literal>error</literal> | | |
682 <literal>timeout</literal> | | |
683 <literal>invalid_header</literal> | | |
684 <literal>http_500</literal> | | |
685 <literal>http_503</literal> | | |
686 <literal>http_403</literal> | | |
687 <literal>http_404</literal> | | |
688 <literal>off</literal> | |
689 ...</syntax> | |
690 <default>error timeout</default> | |
691 <context>http</context> | |
692 <context>server</context> | |
693 <context>location</context> | |
694 | |
695 <para> | |
696 Specifies in which cases a request should be passed to the next server: | |
697 <list type="tag"> | |
698 | |
699 <tag-name><literal>error</literal></tag-name> | |
700 <tag-desc>an error occurred while establishing a connection with the | |
701 server, passing a request to it, or reading the response header;</tag-desc> | |
702 | |
703 <tag-name><literal>timeout</literal></tag-name> | |
704 <tag-desc>a timeout has occurred while establishing a connection with the | |
705 server, passing a request to it, or reading the response header;</tag-desc> | |
706 | |
707 <tag-name><literal>invalid_header</literal></tag-name> | |
708 <tag-desc>a server returned an empty or invalid response;</tag-desc> | |
709 | |
710 <tag-name><literal>http_500</literal></tag-name> | |
711 <tag-desc>a server returned a response with the code 500;</tag-desc> | |
712 | |
713 <tag-name><literal>http_503</literal></tag-name> | |
714 <tag-desc>a server returned a response with the code 503;</tag-desc> | |
715 | |
716 <tag-name><literal>http_403</literal></tag-name> | |
717 <tag-desc>a server returned a response with the code 403;</tag-desc> | |
718 | |
719 <tag-name><literal>http_404</literal></tag-name> | |
720 <tag-desc>a server returned a response with the code 404;</tag-desc> | |
721 | |
722 <tag-name><literal>off</literal></tag-name> | |
723 <tag-desc>disables passing a request to the next server.</tag-desc> | |
724 | |
725 </list> | |
726 </para> | |
727 | |
728 <para> | |
729 One should bear in mind that passing a request to the next server is | |
730 only possible if nothing has been sent to a client yet. | |
731 That is, if an error or timeout occurs in the middle of the | |
732 transferring of a response, fixing this is impossible. | |
733 </para> | |
734 | |
735 <para> | |
736 The directive also defines what is considered an unsuccessful attempt | |
737 of communication with a | |
738 <link doc="ngx_http_upstream_module.xml" id="server"/>. | |
739 The cases of <literal>error</literal>, <literal>timeout</literal> and | |
740 <literal>invalid_header</literal> are always considered unsuccessful attempts, | |
741 even if they are not specified in the directive. | |
742 The cases of <literal>http_500</literal> and <literal>http_503</literal> are | |
743 considered unsuccessful attempts only if they are specified in the directive. | |
744 The cases of <literal>http_403</literal> and <literal>http_404</literal> | |
745 are never considered unsuccessful attempts. | |
746 </para> | |
747 | |
748 </directive> | |
749 | |
750 | |
751 <directive name="scgi_no_cache"> | |
752 <syntax><value>string</value> ...</syntax> | |
753 <default/> | |
754 <context>http</context> | |
755 <context>server</context> | |
756 <context>location</context> | |
757 | |
758 <para> | |
759 Defines conditions under which the response will not be saved to a cache. | |
760 If at least one value of the string parameters is not empty and is not | |
761 equal to “0” then the response will not be saved: | |
762 <example> | |
763 scgi_no_cache $cookie_nocache $arg_nocache$arg_comment; | |
764 scgi_no_cache $http_pragma $http_authorization; | |
765 </example> | |
766 Can be used along with the <link id="scgi_cache_bypass"/> directive. | |
767 </para> | |
768 | |
769 </directive> | |
770 | |
771 | |
772 <directive name="scgi_param"> | |
773 <syntax> | |
774 <value>parameter</value> <value>value</value> | |
775 [<literal>if_not_empty</literal>]</syntax> | |
776 <default/> | |
777 <context>http</context> | |
778 <context>server</context> | |
779 <context>location</context> | |
780 | |
781 <para> | |
782 Sets a <value>parameter</value> that should be passed to the SCGI server. | |
783 The <value>value</value> can contain text, variables, and their combination. | |
784 These directives are inherited from the previous level if and | |
785 only if there are no | |
786 <literal>scgi_param</literal> | |
787 directives defined on the current level. | |
788 </para> | |
789 | |
790 <para> | |
791 Standard | |
792 <link url="http://tools.ietf.org/html/rfc3875#section-4.1">CGI | |
793 environment variables</link> | |
794 should be provided as SCGI headers, see the <path>scgi_params</path> file | |
795 provided in the distribution: | |
796 <example> | |
797 location / { | |
798 include scgi_params; | |
799 ... | |
800 } | |
801 </example> | |
802 </para> | |
803 | |
1182
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
804 <para> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
805 If a directive is specified with <literal>if_not_empty</literal> (1.1.11) then |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
806 such a parameter will not be passed to the server until its value is not empty: |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
807 <example> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
808 scgi_param HTTPS $https if_not_empty; |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
809 </example> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
810 </para> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
811 |
1180 | 812 </directive> |
813 | |
814 | |
815 <directive name="scgi_pass"> | |
816 <syntax><value>address</value></syntax> | |
817 <default/> | |
818 <context>location</context> | |
819 <context>if in location</context> | |
820 | |
821 <para> | |
822 Sets the address of an SCGI server. | |
823 The address can be specified as a domain name or IP address, | |
824 and an optional port: | |
825 <example> | |
826 scgi_pass localhost:9000; | |
827 </example> | |
828 or as a UNIX-domain socket path: | |
829 <example> | |
830 scgi_pass unix:/tmp/scgi.socket; | |
831 </example> | |
832 </para> | |
833 | |
834 <para> | |
835 If a domain name resolves to several addresses, all of them will be | |
836 used in a round-robin fashion. | |
837 In addition, an address can be specified as a | |
838 <link doc="ngx_http_upstream_module.xml">server group</link>. | |
839 </para> | |
840 | |
841 </directive> | |
842 | |
843 | |
844 <directive name="scgi_pass_header"> | |
845 <syntax><value>field</value></syntax> | |
846 <default/> | |
847 <context>http</context> | |
848 <context>server</context> | |
849 <context>location</context> | |
850 | |
851 <para> | |
852 Permits passing <link id="scgi_hide_header">otherwise disabled</link> header | |
853 fields from an SCGI server to a client. | |
854 </para> | |
855 | |
856 </directive> | |
857 | |
858 | |
859 <directive name="scgi_read_timeout"> | |
860 <syntax><value>time</value></syntax> | |
861 <default>60s</default> | |
862 <context>http</context> | |
863 <context>server</context> | |
864 <context>location</context> | |
865 | |
866 <para> | |
867 Defines a timeout for reading a response from the SCGI server. | |
868 The timeout is set only between two successive read operations, | |
869 not for the transmission of the whole response. | |
870 If the SCGI server does not transmit anything within this time, | |
871 the connection is closed. | |
872 </para> | |
873 | |
874 </directive> | |
875 | |
876 | |
877 <directive name="scgi_pass_request_body"> | |
878 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
879 <default>on</default> | |
880 <context>http</context> | |
881 <context>server</context> | |
882 <context>location</context> | |
883 | |
884 <para> | |
885 Indicates whether the original request body is passed | |
886 to the SCGI server. | |
887 See also the <link id="scgi_pass_request_headers"/> directive. | |
888 </para> | |
889 | |
890 </directive> | |
891 | |
892 | |
893 <directive name="scgi_pass_request_headers"> | |
894 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
895 <default>on</default> | |
896 <context>http</context> | |
897 <context>server</context> | |
898 <context>location</context> | |
899 | |
900 <para> | |
901 Indicates whether the header fields of the original request are passed | |
902 to the SCGI server. | |
903 See also the <link id="scgi_pass_request_body"/> directive. | |
904 </para> | |
905 | |
906 </directive> | |
907 | |
908 | |
909 <directive name="scgi_send_timeout"> | |
910 <syntax><value>time</value></syntax> | |
911 <default>60s</default> | |
912 <context>http</context> | |
913 <context>server</context> | |
914 <context>location</context> | |
915 | |
916 <para> | |
917 Sets a timeout for transmitting a request to the SCGI server. | |
918 The timeout is set only between two successive write operations, | |
919 not for the transmission of the whole request. | |
920 If the SCGI server does not receive anything within this time, | |
921 the connection is closed. | |
922 </para> | |
923 | |
924 </directive> | |
925 | |
926 | |
927 <directive name="scgi_store"> | |
928 <syntax> | |
929 <literal>on</literal> | | |
930 <literal>off</literal> | | |
931 <value>string</value></syntax> | |
932 <default>off</default> | |
933 <context>http</context> | |
934 <context>server</context> | |
935 <context>location</context> | |
936 | |
937 <para> | |
938 Enables saving of files to a disk. | |
939 The <literal>on</literal> parameter saves files with paths | |
940 corresponding to the directives | |
941 <link doc="ngx_http_core_module.xml" id="alias"/> or | |
942 <link doc="ngx_http_core_module.xml" id="root"/>. | |
943 The <literal>off</literal> parameter disables saving of files. | |
944 In addition, the file name can be set explicitly using the | |
945 <value>string</value> with variables: | |
946 <example> | |
947 scgi_store /data/www$original_uri; | |
948 </example> | |
949 </para> | |
950 | |
951 <para> | |
952 The modification time of files is set according to the received | |
953 <header>Last-Modified</header> response header field. | |
954 The response is first written to a temporary file, | |
955 and then the file is renamed. | |
956 Starting from version 0.8.9, temporary files and the persistent store | |
957 can be put on different file systems. | |
958 However, be aware that in this case a file is copied | |
959 across two file systems instead of the cheap renaming operation. | |
960 It is thus recommended that for any given location both saved files and a | |
961 directory holding temporary files, set by the <link id="scgi_temp_path"/> | |
962 directive, are put on the same file system. | |
963 </para> | |
964 | |
965 <para> | |
966 This directive can be used to create local copies of static unchangeable | |
967 files, e.g.: | |
968 <example> | |
969 location /images/ { | |
1184
55857cbf562d
Fixed alignment issues after mechanical conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1182
diff
changeset
|
970 root /data/www; |
55857cbf562d
Fixed alignment issues after mechanical conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1182
diff
changeset
|
971 error_page 404 = /fetch$uri; |
1180 | 972 } |
973 | |
974 location /fetch/ { | |
975 internal; | |
976 | |
977 scgi_pass backend:9000; | |
978 ... | |
979 | |
980 scgi_store on; | |
981 scgi_store_access user:rw group:rw all:r; | |
982 scgi_temp_path /data/temp; | |
983 | |
1184
55857cbf562d
Fixed alignment issues after mechanical conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1182
diff
changeset
|
984 alias /data/www/; |
1180 | 985 } |
986 </example> | |
987 </para> | |
988 | |
989 </directive> | |
990 | |
991 | |
992 <directive name="scgi_store_access"> | |
993 <syntax><value>users</value>:<value>permissions</value> ...</syntax> | |
994 <default>user:rw</default> | |
995 <context>http</context> | |
996 <context>server</context> | |
997 <context>location</context> | |
998 | |
999 <para> | |
1000 Sets access permissions for newly created files and directories, e.g.: | |
1001 <example> | |
1002 scgi_store_access user:rw group:rw all:r; | |
1003 </example> | |
1004 </para> | |
1005 | |
1006 <para> | |
1007 If any <literal>group</literal> or <literal>all</literal> access permissions | |
1008 are specified then <literal>user</literal> permissions may be omitted: | |
1009 <example> | |
1010 scgi_store_access group:rw all:r; | |
1011 </example> | |
1012 </para> | |
1013 | |
1014 </directive> | |
1015 | |
1016 | |
1017 <directive name="scgi_temp_file_write_size"> | |
1018 <syntax><value>size</value></syntax> | |
1019 <default>8k|16k</default> | |
1020 <context>http</context> | |
1021 <context>server</context> | |
1022 <context>location</context> | |
1023 | |
1024 <para> | |
1025 Limits the <value>size</value> of data written to a temporary file | |
1026 at a time, when buffering of responses from the SCGI server | |
1027 to temporary files is enabled. | |
1028 By default, <value>size</value> is limited by two buffers set by the | |
1029 <link id="scgi_buffer_size"/> and <link id="scgi_buffers"/> directives. | |
1030 The maximum size of a temporary file is set by the | |
1031 <link id="scgi_max_temp_file_size"/> directive. | |
1032 </para> | |
1033 | |
1034 </directive> | |
1035 | |
1036 | |
1037 <directive name="scgi_temp_path"> | |
1038 <syntax> | |
1039 <value>path</value> | |
1040 [<value>level1</value> | |
1041 [<value>level2</value> | |
1042 [<value>level3</value>]]]</syntax> | |
1043 <default>scgi_temp</default> | |
1044 <context>http</context> | |
1045 <context>server</context> | |
1046 <context>location</context> | |
1047 | |
1048 <para> | |
1049 Defines a directory for storing temporary files | |
1050 with data received from SCGI servers. | |
1051 Up to three-level subdirectory hierarchy can be used underneath the specified | |
1052 directory. | |
1053 For example, in the following configuration | |
1054 <example> | |
1055 scgi_temp_path /spool/nginx/scgi_temp 1 2; | |
1056 </example> | |
1057 a temporary file might look like this: | |
1058 <example> | |
1059 /spool/nginx/scgi_temp/<emphasis>7</emphasis>/<emphasis>45</emphasis>/00000123<emphasis>457</emphasis> | |
1060 </example> | |
1061 </para> | |
1062 | |
1063 </directive> | |
1064 | |
1065 </section> | |
1066 | |
1067 </module> |