Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_scgi_module.xml @ 1185:f9c8336fe43c
Aligned configuration examples with fastcgi/scgi_cache_purge.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 08 May 2014 22:32:42 +0400 |
parents | 55857cbf562d |
children | f25d00109de0 |
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" | |
13 rev="1"> | |
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. | |
333 Cached data that are not accessed during the time specified by the | |
334 <literal>inactive</literal> parameter get removed from the cache | |
335 regardless of their freshness. | |
336 By default, <literal>inactive</literal> is set to 10 minutes. | |
337 </para> | |
338 | |
339 <para> | |
340 The special “cache manager” process monitors the maximum cache size set | |
341 by the <literal>max_size</literal> parameter. | |
342 When this size is exceeded, it removes the least recently used data. | |
343 </para> | |
344 | |
345 <para> | |
346 A minute after the start the special “cache loader” process is activated. | |
347 It loads information about previously cached data stored on file system | |
348 into a cache zone. | |
349 The loading is done in iterations. | |
350 During one iteration no more than <literal>loader_files</literal> items | |
351 are loaded (by default, 100). | |
352 Besides, the duration of one iteration is limited by the | |
353 <literal>loader_threshold</literal> parameter (by default, 200 milliseconds). | |
354 Between iterations, a pause configured by the <literal>loader_sleep</literal> | |
355 parameter (by default, 50 milliseconds) is made. | |
356 </para> | |
357 | |
358 </directive> | |
359 | |
360 | |
361 <directive name="scgi_cache_purge"> | |
362 <syntax>string ...</syntax> | |
363 <default/> | |
364 <context>http</context> | |
365 <context>server</context> | |
366 <context>location</context> | |
367 <appeared-in>1.5.7</appeared-in> | |
368 | |
369 <para> | |
370 Defines conditions under which the request will be considered a cache | |
371 purge request. | |
372 If at least one value of the string parameters is not empty and is not equal | |
373 to “0” then the cache entry with a corresponding | |
374 <link id="scgi_cache_key">cache key</link> is removed. | |
375 The result of successful operation is indicated by returning | |
376 the <http-status code="204" text="No Content"/> response. | |
377 </para> | |
378 | |
379 <para> | |
380 If the <link id="scgi_cache_key">cache key</link> of a purge request ends | |
381 with an asterisk (“<literal>*</literal>”), all cache entries matching the | |
382 wildcard key will be removed from the cache. | |
383 </para> | |
384 | |
385 <para> | |
386 Example configuration: | |
387 <example> | |
388 scgi_cache_path /data/nginx/cache keys_zone=cache_zone:10m; | |
389 | |
390 map $request_method $purge_method { | |
391 PURGE 1; | |
392 default 0; | |
393 } | |
394 | |
395 server { | |
396 ... | |
397 location / { | |
1185
f9c8336fe43c
Aligned configuration examples with fastcgi/scgi_cache_purge.
Ruslan Ermilov <ru@nginx.com>
parents:
1184
diff
changeset
|
398 scgi_pass backend; |
f9c8336fe43c
Aligned configuration examples with fastcgi/scgi_cache_purge.
Ruslan Ermilov <ru@nginx.com>
parents:
1184
diff
changeset
|
399 scgi_cache cache_zone; |
f9c8336fe43c
Aligned configuration examples with fastcgi/scgi_cache_purge.
Ruslan Ermilov <ru@nginx.com>
parents:
1184
diff
changeset
|
400 scgi_cache_key $uri; |
1180 | 401 scgi_cache_purge $purge_method; |
402 } | |
403 } | |
404 </example> | |
405 <note> | |
406 This functionality is available as part of our | |
407 <commercial_version>commercial subscription</commercial_version>. | |
408 </note> | |
409 </para> | |
410 | |
411 </directive> | |
412 | |
413 | |
414 <directive name="scgi_cache_revalidate"> | |
415 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
416 <default>off</default> | |
417 <context>http</context> | |
418 <context>server</context> | |
419 <context>location</context> | |
420 <appeared-in>1.5.7</appeared-in> | |
421 | |
422 <para> | |
423 Enables revalidation of expired cache items using conditional requests with | |
424 the <header>If-Modified-Since</header> header field. | |
425 </para> | |
426 | |
427 </directive> | |
428 | |
429 | |
430 <directive name="scgi_cache_use_stale"> | |
431 <syntax> | |
432 <literal>error</literal> | | |
433 <literal>timeout</literal> | | |
434 <literal>invalid_header</literal> | | |
435 <literal>updating</literal> | | |
436 <literal>http_500</literal> | | |
437 <literal>http_503</literal> | | |
438 <literal>http_403</literal> | | |
439 <literal>http_404</literal> | | |
440 <literal>off</literal> | |
441 ...</syntax> | |
442 <default>off</default> | |
443 <context>http</context> | |
444 <context>server</context> | |
445 <context>location</context> | |
446 | |
447 <para> | |
448 Determines in which cases a stale cached response can be used | |
449 when an error occurs during communication with the SCGI server. | |
450 The directive’s parameters match the parameters of the | |
451 <link id="scgi_next_upstream"/> directive. | |
452 </para> | |
453 | |
454 <para> | |
455 Additionally, the <literal>updating</literal> parameter permits | |
456 using a stale cached response if it is currently being updated. | |
457 This allows minimizing the number of accesses to SCGI servers | |
458 when updating cached data. | |
459 </para> | |
460 | |
461 <para> | |
462 To minimize the number of accesses to SCGI servers when | |
463 populating a new cache element, the <link id="scgi_cache_lock"/> | |
464 directive can be used. | |
465 </para> | |
466 | |
467 </directive> | |
468 | |
469 | |
470 <directive name="scgi_cache_valid"> | |
471 <syntax>[<value>code</value> ...] <value>time</value></syntax> | |
472 <default/> | |
473 <context>http</context> | |
474 <context>server</context> | |
475 <context>location</context> | |
476 | |
477 <para> | |
478 Sets caching time for different response codes. | |
479 For example, the following directives | |
480 <example> | |
481 scgi_cache_valid 200 302 10m; | |
482 scgi_cache_valid 404 1m; | |
483 </example> | |
484 set 10 minutes of caching for responses with codes 200 and 302 | |
485 and 1 minute for responses with code 404. | |
486 </para> | |
487 | |
488 <para> | |
489 If only caching <value>time</value> is specified | |
490 <example> | |
491 scgi_cache_valid 5m; | |
492 </example> | |
493 then only 200, 301, and 302 responses are cached. | |
494 </para> | |
495 | |
496 <para> | |
497 In addition, the <literal>any</literal> parameter can be specified | |
498 to cache any responses: | |
499 <example> | |
500 scgi_cache_valid 200 302 10m; | |
501 scgi_cache_valid 301 1h; | |
502 scgi_cache_valid any 1m; | |
503 </example> | |
504 </para> | |
505 | |
506 <para> | |
507 Parameters of caching can also be set directly | |
508 in the response header. | |
509 This has higher priority than setting of caching time using the directive. | |
510 The <header>X-Accel-Expires</header> header field sets caching time of a | |
511 response in seconds. | |
512 The zero value disables caching for a response. | |
513 If the value starts with the <literal>@</literal> prefix, it sets an absolute | |
514 time in seconds since Epoch, up to which the response may be cached. | |
515 If the header does not include the <header>X-Accel-Expires</header> field, | |
516 parameters of caching may be set in the header fields | |
517 <header>Expires</header> or <header>Cache-Control</header>. | |
518 If the header includes the <header>Set-Cookie</header> field, such a | |
519 response will not be cached. | |
520 Processing of one or more of these response header fields can be disabled | |
521 using the <link id="scgi_ignore_headers"/> directive. | |
522 </para> | |
523 | |
524 </directive> | |
525 | |
526 | |
527 <directive name="scgi_connect_timeout"> | |
528 <syntax><value>time</value></syntax> | |
529 <default>60s</default> | |
530 <context>http</context> | |
531 <context>server</context> | |
532 <context>location</context> | |
533 | |
534 <para> | |
535 Defines a timeout for establishing a connection with an SCGI server. | |
536 It should be noted that this timeout cannot usually exceed 75 seconds. | |
537 </para> | |
538 | |
539 </directive> | |
540 | |
541 | |
542 <directive name="scgi_hide_header"> | |
543 <syntax><value>field</value></syntax> | |
544 <default/> | |
545 <context>http</context> | |
546 <context>server</context> | |
547 <context>location</context> | |
548 | |
549 <para> | |
550 By default, | |
551 nginx does not pass the header fields <header>Status</header> and | |
552 <header>X-Accel-...</header> from the response of an SCGI | |
553 server to a client. | |
554 The <literal>scgi_hide_header</literal> directive sets additional fields | |
555 that will not be passed. | |
556 If, on the contrary, the passing of fields needs to be permitted, | |
557 the <link id="scgi_pass_header"/> directive can be used. | |
558 </para> | |
559 | |
560 </directive> | |
561 | |
562 | |
563 <directive name="scgi_ignore_client_abort"> | |
564 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
565 <default>off</default> | |
566 <context>http</context> | |
567 <context>server</context> | |
568 <context>location</context> | |
569 | |
570 <para> | |
571 Determines whether the connection with an SCGI server should be | |
572 closed when a client closes the connection without waiting | |
573 for a response. | |
574 </para> | |
575 | |
576 </directive> | |
577 | |
578 | |
579 <directive name="scgi_ignore_headers"> | |
580 <syntax><value>field</value> ...</syntax> | |
581 <default/> | |
582 <context>http</context> | |
583 <context>server</context> | |
584 <context>location</context> | |
585 | |
586 <para> | |
587 Disables processing of certain response header fields from the SCGI server. | |
588 The following fields can be ignored: <header>X-Accel-Redirect</header>, | |
589 <header>X-Accel-Expires</header>, <header>X-Accel-Limit-Rate</header> (1.1.6), | |
590 <header>X-Accel-Buffering</header> (1.1.6), | |
591 <header>X-Accel-Charset</header> (1.1.6), <header>Expires</header>, | |
592 <header>Cache-Control</header>, and <header>Set-Cookie</header> (0.8.44). | |
593 </para> | |
594 | |
595 <para> | |
596 If not disabled, processing of these header fields has the following | |
597 effect: | |
598 <list type="bullet" compact="no"> | |
599 | |
600 <listitem> | |
601 <header>X-Accel-Expires</header>, <header>Expires</header>, | |
602 <header>Cache-Control</header>, and <header>Set-Cookie</header> | |
603 set the parameters of response <link id="scgi_cache_valid">caching</link>; | |
604 </listitem> | |
605 | |
606 <listitem> | |
607 <header>X-Accel-Redirect</header> performs an | |
608 <link doc="ngx_http_core_module.xml" id="internal">internal | |
609 redirect</link> to the specified URI; | |
610 </listitem> | |
611 | |
612 <listitem> | |
613 <header>X-Accel-Limit-Rate</header> sets the | |
614 <link doc="ngx_http_core_module.xml" id="limit_rate">rate | |
615 limit</link> for transmission of a response to a client; | |
616 </listitem> | |
617 | |
618 <listitem> | |
619 <header>X-Accel-Buffering</header> enables or disables | |
620 <link id="scgi_buffering">buffering</link> of a response; | |
621 </listitem> | |
622 | |
623 <listitem> | |
624 <header>X-Accel-Charset</header> sets the desired | |
625 <link doc="ngx_http_charset_module.xml" id="charset"/> | |
626 of a response. | |
627 </listitem> | |
628 | |
629 </list> | |
630 </para> | |
631 | |
632 </directive> | |
633 | |
634 | |
635 <directive name="scgi_intercept_errors"> | |
636 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
637 <default>off</default> | |
638 <context>http</context> | |
639 <context>server</context> | |
640 <context>location</context> | |
641 | |
642 <para> | |
643 Determines whether an SCGI server responses with codes greater than or equal | |
644 to 300 should be passed to a client or be redirected to nginx for processing | |
645 with the <link doc="ngx_http_core_module.xml" id="error_page"/> directive. | |
646 </para> | |
647 | |
648 </directive> | |
649 | |
650 | |
651 <directive name="scgi_max_temp_file_size"> | |
652 <syntax><value>size</value></syntax> | |
653 <default>1024m</default> | |
654 <context>http</context> | |
655 <context>server</context> | |
656 <context>location</context> | |
657 | |
658 <para> | |
659 When <link id="scgi_buffering">buffering</link> of responses from the SCGI | |
660 server is enabled, and the whole response does not fit into the buffers | |
661 set by the <link id="scgi_buffer_size"/> and <link id="scgi_buffers"/> | |
662 directives, a part of the response can be saved to a temporary file. | |
663 This directive sets the maximum <value>size</value> of the temporary file. | |
664 The size of data written to the temporary file at a time is set | |
665 by the <link id="scgi_temp_file_write_size"/> directive. | |
666 </para> | |
667 | |
668 <para> | |
669 The zero value disables buffering of responses to temporary files. | |
670 </para> | |
671 | |
672 </directive> | |
673 | |
674 | |
675 <directive name="scgi_next_upstream"> | |
676 <syntax> | |
677 <literal>error</literal> | | |
678 <literal>timeout</literal> | | |
679 <literal>invalid_header</literal> | | |
680 <literal>http_500</literal> | | |
681 <literal>http_503</literal> | | |
682 <literal>http_403</literal> | | |
683 <literal>http_404</literal> | | |
684 <literal>off</literal> | |
685 ...</syntax> | |
686 <default>error timeout</default> | |
687 <context>http</context> | |
688 <context>server</context> | |
689 <context>location</context> | |
690 | |
691 <para> | |
692 Specifies in which cases a request should be passed to the next server: | |
693 <list type="tag"> | |
694 | |
695 <tag-name><literal>error</literal></tag-name> | |
696 <tag-desc>an error occurred while establishing a connection with the | |
697 server, passing a request to it, or reading the response header;</tag-desc> | |
698 | |
699 <tag-name><literal>timeout</literal></tag-name> | |
700 <tag-desc>a timeout has 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>invalid_header</literal></tag-name> | |
704 <tag-desc>a server returned an empty or invalid response;</tag-desc> | |
705 | |
706 <tag-name><literal>http_500</literal></tag-name> | |
707 <tag-desc>a server returned a response with the code 500;</tag-desc> | |
708 | |
709 <tag-name><literal>http_503</literal></tag-name> | |
710 <tag-desc>a server returned a response with the code 503;</tag-desc> | |
711 | |
712 <tag-name><literal>http_403</literal></tag-name> | |
713 <tag-desc>a server returned a response with the code 403;</tag-desc> | |
714 | |
715 <tag-name><literal>http_404</literal></tag-name> | |
716 <tag-desc>a server returned a response with the code 404;</tag-desc> | |
717 | |
718 <tag-name><literal>off</literal></tag-name> | |
719 <tag-desc>disables passing a request to the next server.</tag-desc> | |
720 | |
721 </list> | |
722 </para> | |
723 | |
724 <para> | |
725 One should bear in mind that passing a request to the next server is | |
726 only possible if nothing has been sent to a client yet. | |
727 That is, if an error or timeout occurs in the middle of the | |
728 transferring of a response, fixing this is impossible. | |
729 </para> | |
730 | |
731 <para> | |
732 The directive also defines what is considered an unsuccessful attempt | |
733 of communication with a | |
734 <link doc="ngx_http_upstream_module.xml" id="server"/>. | |
735 The cases of <literal>error</literal>, <literal>timeout</literal> and | |
736 <literal>invalid_header</literal> are always considered unsuccessful attempts, | |
737 even if they are not specified in the directive. | |
738 The cases of <literal>http_500</literal> and <literal>http_503</literal> are | |
739 considered unsuccessful attempts only if they are specified in the directive. | |
740 The cases of <literal>http_403</literal> and <literal>http_404</literal> | |
741 are never considered unsuccessful attempts. | |
742 </para> | |
743 | |
744 </directive> | |
745 | |
746 | |
747 <directive name="scgi_no_cache"> | |
748 <syntax><value>string</value> ...</syntax> | |
749 <default/> | |
750 <context>http</context> | |
751 <context>server</context> | |
752 <context>location</context> | |
753 | |
754 <para> | |
755 Defines conditions under which the response will not be saved to a cache. | |
756 If at least one value of the string parameters is not empty and is not | |
757 equal to “0” then the response will not be saved: | |
758 <example> | |
759 scgi_no_cache $cookie_nocache $arg_nocache$arg_comment; | |
760 scgi_no_cache $http_pragma $http_authorization; | |
761 </example> | |
762 Can be used along with the <link id="scgi_cache_bypass"/> directive. | |
763 </para> | |
764 | |
765 </directive> | |
766 | |
767 | |
768 <directive name="scgi_param"> | |
769 <syntax> | |
770 <value>parameter</value> <value>value</value> | |
771 [<literal>if_not_empty</literal>]</syntax> | |
772 <default/> | |
773 <context>http</context> | |
774 <context>server</context> | |
775 <context>location</context> | |
776 | |
777 <para> | |
778 Sets a <value>parameter</value> that should be passed to the SCGI server. | |
779 The <value>value</value> can contain text, variables, and their combination. | |
780 These directives are inherited from the previous level if and | |
781 only if there are no | |
782 <literal>scgi_param</literal> | |
783 directives defined on the current level. | |
784 </para> | |
785 | |
786 <para> | |
787 Standard | |
788 <link url="http://tools.ietf.org/html/rfc3875#section-4.1">CGI | |
789 environment variables</link> | |
790 should be provided as SCGI headers, see the <path>scgi_params</path> file | |
791 provided in the distribution: | |
792 <example> | |
793 location / { | |
794 include scgi_params; | |
795 ... | |
796 } | |
797 </example> | |
798 </para> | |
799 | |
1182
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
800 <para> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
801 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
|
802 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
|
803 <example> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
804 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
|
805 </example> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
806 </para> |
ec1097156f81
Scgi: restored if_not_empty lost during conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1180
diff
changeset
|
807 |
1180 | 808 </directive> |
809 | |
810 | |
811 <directive name="scgi_pass"> | |
812 <syntax><value>address</value></syntax> | |
813 <default/> | |
814 <context>location</context> | |
815 <context>if in location</context> | |
816 | |
817 <para> | |
818 Sets the address of an SCGI server. | |
819 The address can be specified as a domain name or IP address, | |
820 and an optional port: | |
821 <example> | |
822 scgi_pass localhost:9000; | |
823 </example> | |
824 or as a UNIX-domain socket path: | |
825 <example> | |
826 scgi_pass unix:/tmp/scgi.socket; | |
827 </example> | |
828 </para> | |
829 | |
830 <para> | |
831 If a domain name resolves to several addresses, all of them will be | |
832 used in a round-robin fashion. | |
833 In addition, an address can be specified as a | |
834 <link doc="ngx_http_upstream_module.xml">server group</link>. | |
835 </para> | |
836 | |
837 </directive> | |
838 | |
839 | |
840 <directive name="scgi_pass_header"> | |
841 <syntax><value>field</value></syntax> | |
842 <default/> | |
843 <context>http</context> | |
844 <context>server</context> | |
845 <context>location</context> | |
846 | |
847 <para> | |
848 Permits passing <link id="scgi_hide_header">otherwise disabled</link> header | |
849 fields from an SCGI server to a client. | |
850 </para> | |
851 | |
852 </directive> | |
853 | |
854 | |
855 <directive name="scgi_read_timeout"> | |
856 <syntax><value>time</value></syntax> | |
857 <default>60s</default> | |
858 <context>http</context> | |
859 <context>server</context> | |
860 <context>location</context> | |
861 | |
862 <para> | |
863 Defines a timeout for reading a response from the SCGI server. | |
864 The timeout is set only between two successive read operations, | |
865 not for the transmission of the whole response. | |
866 If the SCGI server does not transmit anything within this time, | |
867 the connection is closed. | |
868 </para> | |
869 | |
870 </directive> | |
871 | |
872 | |
873 <directive name="scgi_pass_request_body"> | |
874 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
875 <default>on</default> | |
876 <context>http</context> | |
877 <context>server</context> | |
878 <context>location</context> | |
879 | |
880 <para> | |
881 Indicates whether the original request body is passed | |
882 to the SCGI server. | |
883 See also the <link id="scgi_pass_request_headers"/> directive. | |
884 </para> | |
885 | |
886 </directive> | |
887 | |
888 | |
889 <directive name="scgi_pass_request_headers"> | |
890 <syntax><literal>on</literal> | <literal>off</literal></syntax> | |
891 <default>on</default> | |
892 <context>http</context> | |
893 <context>server</context> | |
894 <context>location</context> | |
895 | |
896 <para> | |
897 Indicates whether the header fields of the original request are passed | |
898 to the SCGI server. | |
899 See also the <link id="scgi_pass_request_body"/> directive. | |
900 </para> | |
901 | |
902 </directive> | |
903 | |
904 | |
905 <directive name="scgi_send_timeout"> | |
906 <syntax><value>time</value></syntax> | |
907 <default>60s</default> | |
908 <context>http</context> | |
909 <context>server</context> | |
910 <context>location</context> | |
911 | |
912 <para> | |
913 Sets a timeout for transmitting a request to the SCGI server. | |
914 The timeout is set only between two successive write operations, | |
915 not for the transmission of the whole request. | |
916 If the SCGI server does not receive anything within this time, | |
917 the connection is closed. | |
918 </para> | |
919 | |
920 </directive> | |
921 | |
922 | |
923 <directive name="scgi_store"> | |
924 <syntax> | |
925 <literal>on</literal> | | |
926 <literal>off</literal> | | |
927 <value>string</value></syntax> | |
928 <default>off</default> | |
929 <context>http</context> | |
930 <context>server</context> | |
931 <context>location</context> | |
932 | |
933 <para> | |
934 Enables saving of files to a disk. | |
935 The <literal>on</literal> parameter saves files with paths | |
936 corresponding to the directives | |
937 <link doc="ngx_http_core_module.xml" id="alias"/> or | |
938 <link doc="ngx_http_core_module.xml" id="root"/>. | |
939 The <literal>off</literal> parameter disables saving of files. | |
940 In addition, the file name can be set explicitly using the | |
941 <value>string</value> with variables: | |
942 <example> | |
943 scgi_store /data/www$original_uri; | |
944 </example> | |
945 </para> | |
946 | |
947 <para> | |
948 The modification time of files is set according to the received | |
949 <header>Last-Modified</header> response header field. | |
950 The response is first written to a temporary file, | |
951 and then the file is renamed. | |
952 Starting from version 0.8.9, temporary files and the persistent store | |
953 can be put on different file systems. | |
954 However, be aware that in this case a file is copied | |
955 across two file systems instead of the cheap renaming operation. | |
956 It is thus recommended that for any given location both saved files and a | |
957 directory holding temporary files, set by the <link id="scgi_temp_path"/> | |
958 directive, are put on the same file system. | |
959 </para> | |
960 | |
961 <para> | |
962 This directive can be used to create local copies of static unchangeable | |
963 files, e.g.: | |
964 <example> | |
965 location /images/ { | |
1184
55857cbf562d
Fixed alignment issues after mechanical conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1182
diff
changeset
|
966 root /data/www; |
55857cbf562d
Fixed alignment issues after mechanical conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1182
diff
changeset
|
967 error_page 404 = /fetch$uri; |
1180 | 968 } |
969 | |
970 location /fetch/ { | |
971 internal; | |
972 | |
973 scgi_pass backend:9000; | |
974 ... | |
975 | |
976 scgi_store on; | |
977 scgi_store_access user:rw group:rw all:r; | |
978 scgi_temp_path /data/temp; | |
979 | |
1184
55857cbf562d
Fixed alignment issues after mechanical conversion from fastcgi.
Ruslan Ermilov <ru@nginx.com>
parents:
1182
diff
changeset
|
980 alias /data/www/; |
1180 | 981 } |
982 </example> | |
983 </para> | |
984 | |
985 </directive> | |
986 | |
987 | |
988 <directive name="scgi_store_access"> | |
989 <syntax><value>users</value>:<value>permissions</value> ...</syntax> | |
990 <default>user:rw</default> | |
991 <context>http</context> | |
992 <context>server</context> | |
993 <context>location</context> | |
994 | |
995 <para> | |
996 Sets access permissions for newly created files and directories, e.g.: | |
997 <example> | |
998 scgi_store_access user:rw group:rw all:r; | |
999 </example> | |
1000 </para> | |
1001 | |
1002 <para> | |
1003 If any <literal>group</literal> or <literal>all</literal> access permissions | |
1004 are specified then <literal>user</literal> permissions may be omitted: | |
1005 <example> | |
1006 scgi_store_access group:rw all:r; | |
1007 </example> | |
1008 </para> | |
1009 | |
1010 </directive> | |
1011 | |
1012 | |
1013 <directive name="scgi_temp_file_write_size"> | |
1014 <syntax><value>size</value></syntax> | |
1015 <default>8k|16k</default> | |
1016 <context>http</context> | |
1017 <context>server</context> | |
1018 <context>location</context> | |
1019 | |
1020 <para> | |
1021 Limits the <value>size</value> of data written to a temporary file | |
1022 at a time, when buffering of responses from the SCGI server | |
1023 to temporary files is enabled. | |
1024 By default, <value>size</value> is limited by two buffers set by the | |
1025 <link id="scgi_buffer_size"/> and <link id="scgi_buffers"/> directives. | |
1026 The maximum size of a temporary file is set by the | |
1027 <link id="scgi_max_temp_file_size"/> directive. | |
1028 </para> | |
1029 | |
1030 </directive> | |
1031 | |
1032 | |
1033 <directive name="scgi_temp_path"> | |
1034 <syntax> | |
1035 <value>path</value> | |
1036 [<value>level1</value> | |
1037 [<value>level2</value> | |
1038 [<value>level3</value>]]]</syntax> | |
1039 <default>scgi_temp</default> | |
1040 <context>http</context> | |
1041 <context>server</context> | |
1042 <context>location</context> | |
1043 | |
1044 <para> | |
1045 Defines a directory for storing temporary files | |
1046 with data received from SCGI servers. | |
1047 Up to three-level subdirectory hierarchy can be used underneath the specified | |
1048 directory. | |
1049 For example, in the following configuration | |
1050 <example> | |
1051 scgi_temp_path /spool/nginx/scgi_temp 1 2; | |
1052 </example> | |
1053 a temporary file might look like this: | |
1054 <example> | |
1055 /spool/nginx/scgi_temp/<emphasis>7</emphasis>/<emphasis>45</emphasis>/00000123<emphasis>457</emphasis> | |
1056 </example> | |
1057 </para> | |
1058 | |
1059 </directive> | |
1060 | |
1061 </section> | |
1062 | |
1063 </module> |