Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_fastcgi_module.c @ 2667:c1ac00c2bc75
update r2664
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 04 Apr 2009 17:22:26 +0000 |
parents | 8ace9dee8824 |
children | d5896f6608e8 |
rev | line source |
---|---|
479 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_http.h> | |
10 | |
11 | |
12 typedef struct { | |
651 | 13 ngx_http_upstream_conf_t upstream; |
14 | |
15 ngx_str_t index; | |
16 | |
17 ngx_array_t *flushes; | |
18 ngx_array_t *params_len; | |
19 ngx_array_t *params; | |
20 ngx_array_t *params_source; | |
1228 | 21 ngx_array_t *catch_stderr; |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
22 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
23 ngx_array_t *fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
24 ngx_array_t *fastcgi_values; |
2443 | 25 |
2602 | 26 #if (NGX_HTTP_CACHE) |
27 ngx_http_complex_value_t cache_key; | |
28 #endif | |
29 | |
2443 | 30 #if (NGX_PCRE) |
31 ngx_regex_t *split_regex; | |
32 ngx_str_t split_name; | |
33 #endif | |
479 | 34 } ngx_http_fastcgi_loc_conf_t; |
35 | |
36 | |
37 typedef enum { | |
38 ngx_http_fastcgi_st_version = 0, | |
39 ngx_http_fastcgi_st_type, | |
40 ngx_http_fastcgi_st_request_id_hi, | |
41 ngx_http_fastcgi_st_request_id_lo, | |
42 ngx_http_fastcgi_st_content_length_hi, | |
43 ngx_http_fastcgi_st_content_length_lo, | |
44 ngx_http_fastcgi_st_padding_length, | |
45 ngx_http_fastcgi_st_reserved, | |
46 ngx_http_fastcgi_st_data, | |
515 | 47 ngx_http_fastcgi_st_padding |
479 | 48 } ngx_http_fastcgi_state_e; |
49 | |
50 | |
51 typedef struct { | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
52 u_char *start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
53 u_char *end; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
54 } ngx_http_fastcgi_split_part_t; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
55 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
56 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
57 typedef struct { |
651 | 58 ngx_http_fastcgi_state_e state; |
59 u_char *pos; | |
60 u_char *last; | |
61 ngx_uint_t type; | |
62 size_t length; | |
63 size_t padding; | |
64 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
65 ngx_uint_t fastcgi_stdout; /* unsigned :1 */ |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
66 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
67 ngx_array_t *split_parts; |
2443 | 68 |
69 ngx_str_t script_name; | |
70 ngx_str_t path_info; | |
479 | 71 } ngx_http_fastcgi_ctx_t; |
72 | |
73 | |
74 #define NGX_HTTP_FASTCGI_RESPONDER 1 | |
75 | |
76 #define NGX_HTTP_FASTCGI_BEGIN_REQUEST 1 | |
77 #define NGX_HTTP_FASTCGI_ABORT_REQUEST 2 | |
78 #define NGX_HTTP_FASTCGI_END_REQUEST 3 | |
79 #define NGX_HTTP_FASTCGI_PARAMS 4 | |
80 #define NGX_HTTP_FASTCGI_STDIN 5 | |
81 #define NGX_HTTP_FASTCGI_STDOUT 6 | |
82 #define NGX_HTTP_FASTCGI_STDERR 7 | |
83 #define NGX_HTTP_FASTCGI_DATA 8 | |
84 | |
85 | |
86 typedef struct { | |
87 u_char version; | |
88 u_char type; | |
89 u_char request_id_hi; | |
90 u_char request_id_lo; | |
91 u_char content_length_hi; | |
92 u_char content_length_lo; | |
93 u_char padding_length; | |
94 u_char reserved; | |
95 } ngx_http_fastcgi_header_t; | |
96 | |
97 | |
98 typedef struct { | |
99 u_char role_hi; | |
100 u_char role_lo; | |
101 u_char flags; | |
102 u_char reserved[5]; | |
103 } ngx_http_fastcgi_begin_request_t; | |
104 | |
105 | |
509 | 106 typedef struct { |
107 u_char version; | |
108 u_char type; | |
109 u_char request_id_hi; | |
110 u_char request_id_lo; | |
111 } ngx_http_fastcgi_header_small_t; | |
112 | |
113 | |
114 typedef struct { | |
115 ngx_http_fastcgi_header_t h0; | |
116 ngx_http_fastcgi_begin_request_t br; | |
117 ngx_http_fastcgi_header_small_t h1; | |
118 } ngx_http_fastcgi_request_start_t; | |
119 | |
120 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
121 static ngx_int_t ngx_http_fastcgi_eval(ngx_http_request_t *r, |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
122 ngx_http_fastcgi_loc_conf_t *flcf); |
2602 | 123 #if (NGX_HTTP_CACHE) |
124 static ngx_int_t ngx_http_fastcgi_create_key(ngx_http_request_t *r); | |
125 #endif | |
479 | 126 static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r); |
127 static ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r); | |
128 static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r); | |
129 static ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, | |
487 | 130 ngx_buf_t *buf); |
479 | 131 static ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r, |
487 | 132 ngx_http_fastcgi_ctx_t *f); |
479 | 133 static void ngx_http_fastcgi_abort_request(ngx_http_request_t *r); |
134 static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, | |
487 | 135 ngx_int_t rc); |
479 | 136 |
509 | 137 static ngx_int_t ngx_http_fastcgi_add_variables(ngx_conf_t *cf); |
138 static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf); | |
139 static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, | |
140 void *parent, void *child); | |
573 | 141 static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, |
142 ngx_http_variable_value_t *v, uintptr_t data); | |
2443 | 143 static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, |
144 ngx_http_variable_value_t *v, uintptr_t data); | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
145 static ngx_http_fastcgi_ctx_t *ngx_http_fastcgi_split(ngx_http_request_t *r, |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
146 ngx_http_fastcgi_loc_conf_t *flcf); |
509 | 147 |
479 | 148 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, |
487 | 149 void *conf); |
2443 | 150 static char *ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, |
151 ngx_command_t *cmd, void *conf); | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
152 static char *ngx_http_fastcgi_store(ngx_conf_t *cf, ngx_command_t *cmd, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
153 void *conf); |
2602 | 154 #if (NGX_HTTP_CACHE) |
155 static char *ngx_http_fastcgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, | |
156 void *conf); | |
157 static char *ngx_http_fastcgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, | |
158 void *conf); | |
159 #endif | |
160 | |
479 | 161 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, |
487 | 162 void *data); |
479 | 163 |
884 | 164 static char *ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf, |
165 ngx_command_t *cmd, void *conf); | |
166 static char *ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf, | |
167 ngx_command_t *cmd, void *conf); | |
168 | |
479 | 169 |
509 | 170 static ngx_conf_post_t ngx_http_fastcgi_lowat_post = |
171 { ngx_http_fastcgi_lowat_check }; | |
479 | 172 |
173 | |
174 static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = { | |
175 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | |
176 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | |
177 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, | |
178 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, | |
623 | 179 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, |
479 | 180 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, |
665 | 181 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, |
479 | 182 { ngx_null_string, 0 } |
183 }; | |
184 | |
185 | |
2602 | 186 ngx_module_t ngx_http_fastcgi_module; |
187 | |
188 | |
479 | 189 static ngx_command_t ngx_http_fastcgi_commands[] = { |
190 | |
191 { ngx_string("fastcgi_pass"), | |
629 | 192 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, |
479 | 193 ngx_http_fastcgi_pass, |
194 NGX_HTTP_LOC_CONF_OFFSET, | |
195 0, | |
196 NULL }, | |
197 | |
198 { ngx_string("fastcgi_index"), | |
199 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
200 ngx_conf_set_str_slot, | |
201 NGX_HTTP_LOC_CONF_OFFSET, | |
202 offsetof(ngx_http_fastcgi_loc_conf_t, index), | |
203 NULL }, | |
204 | |
2443 | 205 { ngx_string("fastcgi_split_path_info"), |
206 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
207 ngx_http_fastcgi_split_path_info, | |
208 NGX_HTTP_LOC_CONF_OFFSET, | |
209 0, | |
210 NULL }, | |
211 | |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
212 { ngx_string("fastcgi_store"), |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
213 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
214 ngx_http_fastcgi_store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
215 NGX_HTTP_LOC_CONF_OFFSET, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
216 0, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
217 NULL }, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
218 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
219 { ngx_string("fastcgi_store_access"), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
220 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
221 ngx_conf_set_access_slot, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
222 NGX_HTTP_LOC_CONF_OFFSET, |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
223 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.store_access), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
224 NULL }, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
225 |
629 | 226 { ngx_string("fastcgi_ignore_client_abort"), |
227 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
228 ngx_conf_set_flag_slot, | |
229 NGX_HTTP_LOC_CONF_OFFSET, | |
230 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.ignore_client_abort), | |
231 NULL }, | |
232 | |
479 | 233 { ngx_string("fastcgi_connect_timeout"), |
234 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
235 ngx_conf_set_msec_slot, | |
236 NGX_HTTP_LOC_CONF_OFFSET, | |
237 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.connect_timeout), | |
238 NULL }, | |
239 | |
240 { ngx_string("fastcgi_send_timeout"), | |
241 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
242 ngx_conf_set_msec_slot, | |
243 NGX_HTTP_LOC_CONF_OFFSET, | |
244 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_timeout), | |
245 NULL }, | |
246 | |
247 { ngx_string("fastcgi_send_lowat"), | |
248 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
249 ngx_conf_set_size_slot, | |
250 NGX_HTTP_LOC_CONF_OFFSET, | |
251 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_lowat), | |
252 &ngx_http_fastcgi_lowat_post }, | |
253 | |
581 | 254 { ngx_string("fastcgi_buffer_size"), |
255 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
256 ngx_conf_set_size_slot, | |
257 NGX_HTTP_LOC_CONF_OFFSET, | |
258 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffer_size), | |
259 NULL }, | |
260 | |
509 | 261 { ngx_string("fastcgi_pass_request_headers"), |
262 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
263 ngx_conf_set_flag_slot, | |
264 NGX_HTTP_LOC_CONF_OFFSET, | |
265 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_headers), | |
266 NULL }, | |
267 | |
268 { ngx_string("fastcgi_pass_request_body"), | |
269 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
270 ngx_conf_set_flag_slot, | |
271 NGX_HTTP_LOC_CONF_OFFSET, | |
272 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_body), | |
273 NULL }, | |
274 | |
657 | 275 { ngx_string("fastcgi_intercept_errors"), |
276 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
277 ngx_conf_set_flag_slot, | |
278 NGX_HTTP_LOC_CONF_OFFSET, | |
279 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.intercept_errors), | |
280 NULL }, | |
281 | |
479 | 282 { ngx_string("fastcgi_read_timeout"), |
283 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
284 ngx_conf_set_msec_slot, | |
285 NGX_HTTP_LOC_CONF_OFFSET, | |
286 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.read_timeout), | |
287 NULL }, | |
288 | |
289 { ngx_string("fastcgi_buffers"), | |
290 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
291 ngx_conf_set_bufs_slot, | |
292 NGX_HTTP_LOC_CONF_OFFSET, | |
293 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.bufs), | |
294 NULL }, | |
295 | |
296 { ngx_string("fastcgi_busy_buffers_size"), | |
297 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
298 ngx_conf_set_size_slot, | |
299 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 300 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf), |
479 | 301 NULL }, |
302 | |
2602 | 303 #if (NGX_HTTP_CACHE) |
304 | |
305 { ngx_string("fastcgi_cache"), | |
306 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
307 ngx_http_fastcgi_cache, | |
308 NGX_HTTP_LOC_CONF_OFFSET, | |
309 0, | |
310 NULL }, | |
311 | |
312 { ngx_string("fastcgi_cache_key"), | |
313 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
314 ngx_http_fastcgi_cache_key, | |
315 NGX_HTTP_LOC_CONF_OFFSET, | |
316 0, | |
317 NULL }, | |
318 | |
319 { ngx_string("fastcgi_cache_path"), | |
320 NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE, | |
321 ngx_http_file_cache_set_slot, | |
322 0, | |
323 0, | |
324 &ngx_http_fastcgi_module }, | |
325 | |
326 { ngx_string("fastcgi_cache_valid"), | |
327 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
328 ngx_http_file_cache_valid_set_slot, | |
329 NGX_HTTP_LOC_CONF_OFFSET, | |
330 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_valid), | |
331 NULL }, | |
332 | |
333 { ngx_string("proxy_cache_min_uses"), | |
334 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
335 ngx_conf_set_num_slot, | |
336 NGX_HTTP_LOC_CONF_OFFSET, | |
337 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_min_uses), | |
338 NULL }, | |
339 | |
340 { ngx_string("fastcgi_cache_use_stale"), | |
341 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
342 ngx_conf_set_bitmask_slot, | |
343 NGX_HTTP_LOC_CONF_OFFSET, | |
344 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_use_stale), | |
345 &ngx_http_fastcgi_next_upstream_masks }, | |
346 | |
347 #endif | |
348 | |
479 | 349 { ngx_string("fastcgi_temp_path"), |
350 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
351 ngx_conf_set_path_slot, | |
352 NGX_HTTP_LOC_CONF_OFFSET, | |
353 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_path), | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
354 NULL }, |
479 | 355 |
356 { ngx_string("fastcgi_max_temp_file_size"), | |
357 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
358 ngx_conf_set_size_slot, | |
359 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 360 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size_conf), |
479 | 361 NULL }, |
362 | |
363 { ngx_string("fastcgi_temp_file_write_size"), | |
364 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
365 ngx_conf_set_size_slot, | |
366 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 367 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size_conf), |
479 | 368 NULL }, |
369 | |
370 { ngx_string("fastcgi_next_upstream"), | |
547 | 371 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
479 | 372 ngx_conf_set_bitmask_slot, |
373 NGX_HTTP_LOC_CONF_OFFSET, | |
374 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream), | |
375 &ngx_http_fastcgi_next_upstream_masks }, | |
376 | |
561 | 377 { ngx_string("fastcgi_upstream_max_fails"), |
378 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
884 | 379 ngx_http_fastcgi_upstream_max_fails_unsupported, |
380 0, | |
381 0, | |
561 | 382 NULL }, |
383 | |
384 { ngx_string("fastcgi_upstream_fail_timeout"), | |
385 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
884 | 386 ngx_http_fastcgi_upstream_fail_timeout_unsupported, |
387 0, | |
388 0, | |
561 | 389 NULL }, |
390 | |
509 | 391 { ngx_string("fastcgi_param"), |
392 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
649 | 393 ngx_conf_set_keyval_slot, |
485 | 394 NGX_HTTP_LOC_CONF_OFFSET, |
509 | 395 offsetof(ngx_http_fastcgi_loc_conf_t, params_source), |
485 | 396 NULL }, |
397 | |
649 | 398 { ngx_string("fastcgi_pass_header"), |
399 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
400 ngx_conf_set_str_array_slot, | |
401 NGX_HTTP_LOC_CONF_OFFSET, | |
402 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_headers), | |
403 NULL }, | |
404 | |
405 { ngx_string("fastcgi_hide_header"), | |
406 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
407 ngx_conf_set_str_array_slot, | |
408 NGX_HTTP_LOC_CONF_OFFSET, | |
409 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.hide_headers), | |
410 NULL }, | |
411 | |
1228 | 412 { ngx_string("fastcgi_catch_stderr"), |
413 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
414 ngx_conf_set_str_array_slot, | |
415 NGX_HTTP_LOC_CONF_OFFSET, | |
416 offsetof(ngx_http_fastcgi_loc_conf_t, catch_stderr), | |
417 NULL }, | |
418 | |
479 | 419 ngx_null_command |
420 }; | |
421 | |
422 | |
667 | 423 static ngx_http_module_t ngx_http_fastcgi_module_ctx = { |
509 | 424 ngx_http_fastcgi_add_variables, /* preconfiguration */ |
425 NULL, /* postconfiguration */ | |
479 | 426 |
427 NULL, /* create main configuration */ | |
428 NULL, /* init main configuration */ | |
429 | |
430 NULL, /* create server configuration */ | |
431 NULL, /* merge server configuration */ | |
432 | |
433 ngx_http_fastcgi_create_loc_conf, /* create location configuration */ | |
434 ngx_http_fastcgi_merge_loc_conf /* merge location configuration */ | |
435 }; | |
436 | |
437 | |
438 ngx_module_t ngx_http_fastcgi_module = { | |
509 | 439 NGX_MODULE_V1, |
479 | 440 &ngx_http_fastcgi_module_ctx, /* module context */ |
441 ngx_http_fastcgi_commands, /* module directives */ | |
442 NGX_HTTP_MODULE, /* module type */ | |
541 | 443 NULL, /* init master */ |
479 | 444 NULL, /* init module */ |
541 | 445 NULL, /* init process */ |
446 NULL, /* init thread */ | |
447 NULL, /* exit thread */ | |
448 NULL, /* exit process */ | |
449 NULL, /* exit master */ | |
450 NGX_MODULE_V1_PADDING | |
479 | 451 }; |
452 | |
453 | |
1883 | 454 static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = { |
455 { 1, /* version */ | |
456 NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */ | |
457 0, /* request_id_hi */ | |
458 1, /* request_id_lo */ | |
459 0, /* content_length_hi */ | |
460 sizeof(ngx_http_fastcgi_begin_request_t), /* content_length_lo */ | |
461 0, /* padding_length */ | |
462 0 }, /* reserved */ | |
463 | |
464 { 0, /* role_hi */ | |
465 NGX_HTTP_FASTCGI_RESPONDER, /* role_lo */ | |
466 0, /* NGX_HTTP_FASTCGI_KEEP_CONN */ /* flags */ | |
467 { 0, 0, 0, 0, 0 } }, /* reserved[5] */ | |
468 | |
469 { 1, /* version */ | |
470 NGX_HTTP_FASTCGI_PARAMS, /* type */ | |
471 0, /* request_id_hi */ | |
472 1 }, /* request_id_lo */ | |
473 | |
474 }; | |
475 | |
476 | |
2443 | 477 static ngx_http_variable_t ngx_http_fastcgi_vars[] = { |
478 | |
479 { ngx_string("fastcgi_script_name"), NULL, | |
480 ngx_http_fastcgi_script_name_variable, 0, | |
481 NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, | |
482 | |
483 { ngx_string("fastcgi_path_info"), NULL, | |
484 ngx_http_fastcgi_path_info_variable, 0, | |
485 NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, | |
486 | |
487 { ngx_null_string, NULL, NULL, 0, 0, 0 } | |
488 }; | |
1884 | 489 |
490 | |
649 | 491 static ngx_str_t ngx_http_fastcgi_hide_headers[] = { |
492 ngx_string("Status"), | |
493 ngx_string("X-Accel-Expires"), | |
494 ngx_string("X-Accel-Redirect"), | |
495 ngx_string("X-Accel-Limit-Rate"), | |
1886
2819956d1ca0
add X-Accel-Charset to ingored header, fix X-Accel-Buffering
Igor Sysoev <igor@sysoev.ru>
parents:
1884
diff
changeset
|
496 ngx_string("X-Accel-Buffering"), |
2819956d1ca0
add X-Accel-Charset to ingored header, fix X-Accel-Buffering
Igor Sysoev <igor@sysoev.ru>
parents:
1884
diff
changeset
|
497 ngx_string("X-Accel-Charset"), |
649 | 498 ngx_null_string |
499 }; | |
500 | |
501 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
502 static ngx_path_init_t ngx_http_fastcgi_temp_path = { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
503 ngx_string(NGX_HTTP_FASTCGI_TEMP_PATH), { 1, 2, 0 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
504 }; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
505 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
506 |
487 | 507 static ngx_int_t |
508 ngx_http_fastcgi_handler(ngx_http_request_t *r) | |
479 | 509 { |
510 ngx_int_t rc; | |
511 ngx_http_upstream_t *u; | |
2443 | 512 ngx_http_fastcgi_ctx_t *f; |
479 | 513 ngx_http_fastcgi_loc_conf_t *flcf; |
514 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
515 if (r->subrequest_in_memory) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
516 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
517 "ngx_http_fastcgi_module does not support " |
1635 | 518 "subrequest in memory"); |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
519 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
520 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
521 |
2443 | 522 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
523 if (f == NULL) { | |
524 return NGX_ERROR; | |
525 } | |
526 | |
527 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); | |
2395
b1a24d3cf4dd
clear fastcgi ctx for internal redirection via named location
Igor Sysoev <igor@sysoev.ru>
parents:
2391
diff
changeset
|
528 |
501 | 529 u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)); |
530 if (u == NULL) { | |
479 | 531 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
532 } | |
533 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
534 r->upstream = u; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
535 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
536 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
537 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
538 if (flcf->fastcgi_lengths) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
539 if (ngx_http_fastcgi_eval(r, flcf) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
540 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
541 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
542 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
543 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
544 u->schema.len = sizeof("fastcgi://") - 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
545 u->schema.data = (u_char *) "fastcgi://"; |
1658 | 546 |
479 | 547 u->peer.log = r->connection->log; |
548 u->peer.log_error = NGX_ERROR_ERR; | |
549 #if (NGX_THREADS) | |
550 u->peer.lock = &r->connection->lock; | |
551 #endif | |
552 | |
553 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module; | |
554 | |
555 u->conf = &flcf->upstream; | |
556 | |
2602 | 557 #if (NGX_HTTP_CACHE) |
558 u->create_key = ngx_http_fastcgi_create_key; | |
559 #endif | |
479 | 560 u->create_request = ngx_http_fastcgi_create_request; |
561 u->reinit_request = ngx_http_fastcgi_reinit_request; | |
562 u->process_header = ngx_http_fastcgi_process_header; | |
563 u->abort_request = ngx_http_fastcgi_abort_request; | |
564 u->finalize_request = ngx_http_fastcgi_finalize_request; | |
565 | |
649 | 566 u->buffering = 1; |
567 | |
581 | 568 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); |
569 if (u->pipe == NULL) { | |
570 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
571 } | |
572 | |
573 u->pipe->input_filter = ngx_http_fastcgi_input_filter; | |
574 u->pipe->input_ctx = r; | |
479 | 575 |
576 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); | |
577 | |
578 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
579 return rc; | |
580 } | |
581 | |
582 return NGX_DONE; | |
583 } | |
584 | |
585 | |
487 | 586 static ngx_int_t |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
587 ngx_http_fastcgi_eval(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
588 { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
589 ngx_url_t u; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
590 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
591 ngx_memzero(&u, sizeof(ngx_url_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
592 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
593 if (ngx_http_script_run(r, &u.url, flcf->fastcgi_lengths->elts, 0, |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
594 flcf->fastcgi_values->elts) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
595 == NULL) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
596 { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
597 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
598 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
599 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
600 u.no_resolve = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
601 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
602 if (ngx_parse_url(r->pool, &u) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
603 if (u.err) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
604 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
605 "%s in upstream \"%V\"", u.err, &u.url); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
606 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
607 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
608 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
609 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
610 |
2396
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
611 if (u.no_port) { |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
612 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
2602 | 613 "no port in upstream \"%V\"", &u.url); |
2396
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
614 return NGX_ERROR; |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
615 } |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
616 |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
617 r->upstream->resolved = ngx_pcalloc(r->pool, |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
618 sizeof(ngx_http_upstream_resolved_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
619 if (r->upstream->resolved == NULL) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
620 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
621 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
622 |
2430
d3454e719bbb
fix segfault, introduced in r2423
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
623 if (u.addrs && u.addrs[0].sockaddr) { |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
624 r->upstream->resolved->sockaddr = u.addrs[0].sockaddr; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
625 r->upstream->resolved->socklen = u.addrs[0].socklen; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
626 r->upstream->resolved->naddrs = 1; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
627 r->upstream->resolved->host = u.addrs[0].name; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
628 |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
629 } else { |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
630 r->upstream->resolved->host = u.host; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
631 r->upstream->resolved->port = u.port; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
632 } |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
633 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
634 return NGX_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
635 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
636 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
637 |
2602 | 638 #if (NGX_HTTP_CACHE) |
639 | |
640 static ngx_int_t | |
641 ngx_http_fastcgi_create_key(ngx_http_request_t *r) | |
642 { | |
643 ngx_str_t *key; | |
644 ngx_http_fastcgi_loc_conf_t *flcf; | |
645 | |
646 key = ngx_array_push(&r->cache->keys); | |
647 if (key == NULL) { | |
648 return NGX_ERROR; | |
649 } | |
650 | |
651 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); | |
652 | |
653 if (ngx_http_complex_value(r, &flcf->cache_key, key) != NGX_OK) { | |
654 return NGX_ERROR; | |
655 } | |
656 | |
657 return NGX_OK; | |
658 } | |
659 | |
660 #endif | |
661 | |
662 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
663 static ngx_int_t |
487 | 664 ngx_http_fastcgi_create_request(ngx_http_request_t *r) |
479 | 665 { |
509 | 666 off_t file_pos; |
667 u_char ch, *pos; | |
668 size_t size, len, key_len, val_len, padding; | |
669 ngx_uint_t i, n, next; | |
670 ngx_buf_t *b; | |
671 ngx_chain_t *cl, *body; | |
672 ngx_list_part_t *part; | |
673 ngx_table_elt_t *header; | |
674 ngx_http_script_code_pt code; | |
675 ngx_http_script_engine_t e, le; | |
676 ngx_http_fastcgi_header_t *h; | |
677 ngx_http_fastcgi_loc_conf_t *flcf; | |
678 ngx_http_script_len_code_pt lcode; | |
479 | 679 |
509 | 680 len = 0; |
485 | 681 |
479 | 682 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
683 | |
509 | 684 if (flcf->params_len) { |
685 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
479 | 686 |
1565 | 687 ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes); |
573 | 688 le.flushed = 1; |
689 | |
509 | 690 le.ip = flcf->params_len->elts; |
691 le.request = r; | |
479 | 692 |
509 | 693 while (*(uintptr_t *) le.ip) { |
487 | 694 |
509 | 695 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
696 key_len = lcode(&le); | |
479 | 697 |
509 | 698 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
699 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
700 } | |
701 le.ip += sizeof(uintptr_t); | |
479 | 702 |
537 | 703 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; |
485 | 704 } |
705 } | |
706 | |
509 | 707 if (flcf->upstream.pass_request_headers) { |
485 | 708 |
509 | 709 part = &r->headers_in.headers.part; |
710 header = part->elts; | |
711 | |
712 for (i = 0; /* void */; i++) { | |
479 | 713 |
509 | 714 if (i >= part->nelts) { |
715 if (part->next == NULL) { | |
716 break; | |
717 } | |
479 | 718 |
509 | 719 part = part->next; |
720 header = part->elts; | |
721 i = 0; | |
479 | 722 } |
723 | |
509 | 724 len += ((sizeof("HTTP_") - 1 + header[i].key.len > 127) ? 4 : 1) |
725 + ((header[i].value.len > 127) ? 4 : 1) | |
726 + sizeof("HTTP_") - 1 + header[i].key.len + header[i].value.len; | |
479 | 727 } |
728 } | |
729 | |
730 | |
731 if (len > 65535) { | |
732 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
1678 | 733 "fastcgi request record is too big: %uz", len); |
479 | 734 return NGX_ERROR; |
735 } | |
736 | |
737 | |
738 padding = 8 - len % 8; | |
739 padding = (padding == 8) ? 0 : padding; | |
740 | |
741 | |
742 size = sizeof(ngx_http_fastcgi_header_t) | |
743 + sizeof(ngx_http_fastcgi_begin_request_t) | |
744 | |
745 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
746 + len + padding | |
747 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
748 | |
749 + sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */ | |
750 | |
751 | |
501 | 752 b = ngx_create_temp_buf(r->pool, size); |
753 if (b == NULL) { | |
479 | 754 return NGX_ERROR; |
755 } | |
756 | |
501 | 757 cl = ngx_alloc_chain_link(r->pool); |
758 if (cl == NULL) { | |
479 | 759 return NGX_ERROR; |
760 } | |
761 | |
762 cl->buf = b; | |
763 | |
509 | 764 ngx_memcpy(b->pos, &ngx_http_fastcgi_request_start, |
765 sizeof(ngx_http_fastcgi_request_start_t)); | |
479 | 766 |
767 h = (ngx_http_fastcgi_header_t *) | |
768 (b->pos + sizeof(ngx_http_fastcgi_header_t) | |
769 + sizeof(ngx_http_fastcgi_begin_request_t)); | |
770 | |
771 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
772 h->content_length_lo = (u_char) (len & 0xff); | |
773 h->padding_length = (u_char) padding; | |
774 h->reserved = 0; | |
775 | |
776 b->last = b->pos + sizeof(ngx_http_fastcgi_header_t) | |
777 + sizeof(ngx_http_fastcgi_begin_request_t) | |
778 + sizeof(ngx_http_fastcgi_header_t); | |
779 | |
780 | |
509 | 781 if (flcf->params_len) { |
782 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
479 | 783 |
509 | 784 e.ip = flcf->params->elts; |
785 e.pos = b->last; | |
786 e.request = r; | |
573 | 787 e.flushed = 1; |
479 | 788 |
509 | 789 le.ip = flcf->params_len->elts; |
479 | 790 |
509 | 791 while (*(uintptr_t *) le.ip) { |
479 | 792 |
509 | 793 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
794 key_len = (u_char) lcode(&le); | |
479 | 795 |
509 | 796 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
797 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
798 } | |
799 le.ip += sizeof(uintptr_t); | |
479 | 800 |
537 | 801 *e.pos++ = (u_char) key_len; |
479 | 802 |
537 | 803 if (val_len > 127) { |
804 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); | |
805 *e.pos++ = (u_char) ((val_len >> 16) & 0xff); | |
806 *e.pos++ = (u_char) ((val_len >> 8) & 0xff); | |
807 *e.pos++ = (u_char) (val_len & 0xff); | |
479 | 808 |
537 | 809 } else { |
810 *e.pos++ = (u_char) val_len; | |
509 | 811 } |
479 | 812 |
509 | 813 while (*(uintptr_t *) e.ip) { |
814 code = *(ngx_http_script_code_pt *) e.ip; | |
815 code((ngx_http_script_engine_t *) &e); | |
816 } | |
817 e.ip += sizeof(uintptr_t); | |
1945 | 818 |
819 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
820 "fastcgi param: \"%*s: %*s\"", | |
821 key_len, e.pos - (key_len + val_len), | |
822 val_len, e.pos - val_len); | |
479 | 823 } |
824 | |
509 | 825 b->last = e.pos; |
487 | 826 } |
827 | |
828 | |
509 | 829 if (flcf->upstream.pass_request_headers) { |
479 | 830 |
509 | 831 part = &r->headers_in.headers.part; |
832 header = part->elts; | |
479 | 833 |
509 | 834 for (i = 0; /* void */; i++) { |
491 | 835 |
509 | 836 if (i >= part->nelts) { |
837 if (part->next == NULL) { | |
577 | 838 break; |
509 | 839 } |
577 | 840 |
509 | 841 part = part->next; |
842 header = part->elts; | |
843 i = 0; | |
844 } | |
479 | 845 |
509 | 846 len = sizeof("HTTP_") - 1 + header[i].key.len; |
847 if (len > 127) { | |
848 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80); | |
849 *b->last++ = (u_char) ((len >> 16) & 0xff); | |
850 *b->last++ = (u_char) ((len >> 8) & 0xff); | |
851 *b->last++ = (u_char) (len & 0xff); | |
577 | 852 |
509 | 853 } else { |
854 *b->last++ = (u_char) len; | |
487 | 855 } |
856 | |
509 | 857 len = header[i].value.len; |
858 if (len > 127) { | |
859 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80); | |
860 *b->last++ = (u_char) ((len >> 16) & 0xff); | |
861 *b->last++ = (u_char) ((len >> 8) & 0xff); | |
862 *b->last++ = (u_char) (len & 0xff); | |
487 | 863 |
509 | 864 } else { |
865 *b->last++ = (u_char) len; | |
479 | 866 } |
867 | |
509 | 868 b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1); |
479 | 869 |
509 | 870 for (n = 0; n < header[i].key.len; n++) { |
871 ch = header[i].key.data[n]; | |
479 | 872 |
509 | 873 if (ch >= 'a' && ch <= 'z') { |
874 ch &= ~0x20; | |
479 | 875 |
509 | 876 } else if (ch == '-') { |
877 ch = '_'; | |
878 } | |
479 | 879 |
509 | 880 *b->last++ = ch; |
479 | 881 } |
882 | |
573 | 883 b->last = ngx_copy(b->last, header[i].value.data, |
884 header[i].value.len); | |
479 | 885 } |
886 } | |
887 | |
888 | |
889 if (padding) { | |
890 ngx_memzero(b->last, padding); | |
891 b->last += padding; | |
892 } | |
893 | |
894 | |
895 h = (ngx_http_fastcgi_header_t *) b->last; | |
896 b->last += sizeof(ngx_http_fastcgi_header_t); | |
897 | |
898 h->version = 1; | |
899 h->type = NGX_HTTP_FASTCGI_PARAMS; | |
900 h->request_id_hi = 0; | |
901 h->request_id_lo = 1; | |
902 h->content_length_hi = 0; | |
903 h->content_length_lo = 0; | |
904 h->padding_length = 0; | |
905 h->reserved = 0; | |
906 | |
907 h = (ngx_http_fastcgi_header_t *) b->last; | |
908 b->last += sizeof(ngx_http_fastcgi_header_t); | |
909 | |
509 | 910 if (flcf->upstream.pass_request_body) { |
911 body = r->upstream->request_bufs; | |
912 r->upstream->request_bufs = cl; | |
479 | 913 |
914 #if (NGX_SUPPRESS_WARN) | |
509 | 915 file_pos = 0; |
916 pos = NULL; | |
479 | 917 #endif |
918 | |
509 | 919 while (body) { |
479 | 920 |
509 | 921 if (body->buf->in_file) { |
922 file_pos = body->buf->file_pos; | |
479 | 923 |
509 | 924 } else { |
925 pos = body->buf->pos; | |
479 | 926 } |
927 | |
509 | 928 next = 0; |
479 | 929 |
509 | 930 do { |
931 b = ngx_alloc_buf(r->pool); | |
932 if (b == NULL) { | |
933 return NGX_ERROR; | |
479 | 934 } |
935 | |
509 | 936 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); |
937 | |
938 if (body->buf->in_file) { | |
939 b->file_pos = file_pos; | |
940 file_pos += 32 * 1024; | |
479 | 941 |
1142
e479e0b02e5a
fix "zero size buf" if request body file is multiple of 32K and FastCGI is used
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
942 if (file_pos >= body->buf->file_last) { |
509 | 943 file_pos = body->buf->file_last; |
944 next = 1; | |
945 } | |
946 | |
947 b->file_last = file_pos; | |
948 len = (ngx_uint_t) (file_pos - b->file_pos); | |
949 | |
950 } else { | |
951 b->pos = pos; | |
952 pos += 32 * 1024; | |
479 | 953 |
1142
e479e0b02e5a
fix "zero size buf" if request body file is multiple of 32K and FastCGI is used
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
954 if (pos >= body->buf->last) { |
509 | 955 pos = body->buf->last; |
956 next = 1; | |
957 } | |
958 | |
959 b->last = pos; | |
960 len = (ngx_uint_t) (pos - b->pos); | |
961 } | |
479 | 962 |
509 | 963 padding = 8 - len % 8; |
964 padding = (padding == 8) ? 0 : padding; | |
479 | 965 |
509 | 966 h->version = 1; |
967 h->type = NGX_HTTP_FASTCGI_STDIN; | |
968 h->request_id_hi = 0; | |
969 h->request_id_lo = 1; | |
970 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
971 h->content_length_lo = (u_char) (len & 0xff); | |
972 h->padding_length = (u_char) padding; | |
973 h->reserved = 0; | |
479 | 974 |
509 | 975 cl->next = ngx_alloc_chain_link(r->pool); |
976 if (cl->next == NULL) { | |
977 return NGX_ERROR; | |
978 } | |
479 | 979 |
509 | 980 cl = cl->next; |
981 cl->buf = b; | |
982 | |
983 b = ngx_create_temp_buf(r->pool, | |
984 sizeof(ngx_http_fastcgi_header_t) | |
985 + padding); | |
986 if (b == NULL) { | |
987 return NGX_ERROR; | |
988 } | |
479 | 989 |
509 | 990 if (padding) { |
991 ngx_memzero(b->last, padding); | |
992 b->last += padding; | |
993 } | |
994 | |
995 h = (ngx_http_fastcgi_header_t *) b->last; | |
996 b->last += sizeof(ngx_http_fastcgi_header_t); | |
479 | 997 |
509 | 998 cl->next = ngx_alloc_chain_link(r->pool); |
999 if (cl->next == NULL) { | |
1000 return NGX_ERROR; | |
1001 } | |
1002 | |
1003 cl = cl->next; | |
1004 cl->buf = b; | |
479 | 1005 |
509 | 1006 } while (!next); |
479 | 1007 |
509 | 1008 body = body->next; |
1009 } | |
479 | 1010 |
509 | 1011 } else { |
1012 r->upstream->request_bufs = cl; | |
479 | 1013 } |
1014 | |
1015 h->version = 1; | |
1016 h->type = NGX_HTTP_FASTCGI_STDIN; | |
1017 h->request_id_hi = 0; | |
1018 h->request_id_lo = 1; | |
1019 h->content_length_hi = 0; | |
1020 h->content_length_lo = 0; | |
1021 h->padding_length = 0; | |
1022 h->reserved = 0; | |
1023 | |
1024 cl->next = NULL; | |
1025 | |
1026 return NGX_OK; | |
1027 } | |
1028 | |
1029 | |
487 | 1030 static ngx_int_t |
1031 ngx_http_fastcgi_reinit_request(ngx_http_request_t *r) | |
479 | 1032 { |
1033 ngx_http_fastcgi_ctx_t *f; | |
1034 | |
1035 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1036 | |
1037 if (f == NULL) { | |
1038 return NGX_OK; | |
1039 } | |
1040 | |
1041 f->state = ngx_http_fastcgi_st_version; | |
615 | 1042 f->fastcgi_stdout = 0; |
479 | 1043 |
1044 return NGX_OK; | |
1045 } | |
1046 | |
1047 | |
507 | 1048 static ngx_int_t |
1049 ngx_http_fastcgi_process_header(ngx_http_request_t *r) | |
479 | 1050 { |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1051 u_char *p, *start, *last, *part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1052 size_t size; |
1228 | 1053 ngx_str_t *status_line, line, *pattern; |
509 | 1054 ngx_int_t rc, status; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1055 ngx_buf_t buf; |
649 | 1056 ngx_uint_t i; |
509 | 1057 ngx_table_elt_t *h; |
1058 ngx_http_upstream_t *u; | |
1059 ngx_http_fastcgi_ctx_t *f; | |
1060 ngx_http_upstream_header_t *hh; | |
1228 | 1061 ngx_http_fastcgi_loc_conf_t *flcf; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1062 ngx_http_fastcgi_split_part_t *part; |
509 | 1063 ngx_http_upstream_main_conf_t *umcf; |
479 | 1064 |
1065 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1066 | |
509 | 1067 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); |
1068 | |
479 | 1069 u = r->upstream; |
1070 | |
1071 for ( ;; ) { | |
1072 | |
1073 if (f->state < ngx_http_fastcgi_st_data) { | |
1074 | |
581 | 1075 f->pos = u->buffer.pos; |
1076 f->last = u->buffer.last; | |
479 | 1077 |
1078 rc = ngx_http_fastcgi_process_record(r, f); | |
1079 | |
581 | 1080 u->buffer.pos = f->pos; |
1081 u->buffer.last = f->last; | |
479 | 1082 |
1083 if (rc == NGX_AGAIN) { | |
1084 return NGX_AGAIN; | |
1085 } | |
1086 | |
1087 if (rc == NGX_ERROR) { | |
1088 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1089 } | |
1090 | |
491 | 1091 if (f->type != NGX_HTTP_FASTCGI_STDOUT |
1092 && f->type != NGX_HTTP_FASTCGI_STDERR) | |
1093 { | |
479 | 1094 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1095 "upstream sent unexpected FastCGI record: %d", | |
1096 f->type); | |
1097 | |
1098 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1099 } | |
1100 | |
491 | 1101 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { |
479 | 1102 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1103 "upstream closed prematurely FastCGI stdout"); | |
1104 | |
1105 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1106 } | |
1107 } | |
1108 | |
1109 if (f->state == ngx_http_fastcgi_st_padding) { | |
1110 | |
581 | 1111 if (u->buffer.pos + f->padding < u->buffer.last) { |
479 | 1112 f->state = ngx_http_fastcgi_st_version; |
581 | 1113 u->buffer.pos += f->padding; |
479 | 1114 |
1115 continue; | |
1116 } | |
1117 | |
581 | 1118 if (u->buffer.pos + f->padding == u->buffer.last) { |
479 | 1119 f->state = ngx_http_fastcgi_st_version; |
581 | 1120 u->buffer.pos = u->buffer.last; |
479 | 1121 |
1122 return NGX_AGAIN; | |
1123 } | |
1124 | |
581 | 1125 f->padding -= u->buffer.last - u->buffer.pos; |
1126 u->buffer.pos = u->buffer.last; | |
479 | 1127 |
1128 return NGX_AGAIN; | |
1129 } | |
1130 | |
491 | 1131 |
479 | 1132 /* f->state == ngx_http_fastcgi_st_data */ |
1133 | |
491 | 1134 if (f->type == NGX_HTTP_FASTCGI_STDERR) { |
1135 | |
1136 if (f->length) { | |
581 | 1137 line.data = u->buffer.pos; |
491 | 1138 |
581 | 1139 if (u->buffer.pos + f->length <= u->buffer.last) { |
491 | 1140 line.len = f->length; |
581 | 1141 u->buffer.pos += f->length; |
491 | 1142 f->length = 0; |
1143 f->state = ngx_http_fastcgi_st_padding; | |
1144 | |
577 | 1145 } else { |
581 | 1146 line.len = u->buffer.last - u->buffer.pos; |
1147 f->length -= u->buffer.last - u->buffer.pos; | |
1148 u->buffer.pos = u->buffer.last; | |
491 | 1149 } |
1150 | |
1151 while (line.data[line.len - 1] == LF | |
1152 || line.data[line.len - 1] == CR | |
1153 || line.data[line.len - 1] == '.' | |
1154 || line.data[line.len - 1] == ' ') | |
1155 { | |
1156 line.len--; | |
1157 } | |
1158 | |
1159 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1160 "FastCGI sent in stderr: \"%V\"", &line); | |
1161 | |
1228 | 1162 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
1163 | |
1164 if (flcf->catch_stderr) { | |
1165 pattern = flcf->catch_stderr->elts; | |
1166 | |
1167 line.data[line.len - 1] = '\0'; | |
1168 | |
1169 for (i = 0; i < flcf->catch_stderr->nelts; i++) { | |
1170 if (ngx_strstr(line.data, pattern[i].data)) { | |
1700
7f3350b18e75
return NGX_HTTP_UPSTREAM_INVALID_HEADER instead of NGX_HTTP_BAD_GATEWAY
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
1171 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
1228 | 1172 } |
1173 } | |
1174 } | |
1175 | |
581 | 1176 if (u->buffer.pos == u->buffer.last) { |
615 | 1177 |
1178 if (!f->fastcgi_stdout) { | |
1179 | |
1180 /* | |
1181 * the special handling the large number | |
1182 * of the PHP warnings to not allocate memory | |
1183 */ | |
1184 | |
1185 u->buffer.pos = u->buffer.start; | |
1186 u->buffer.last = u->buffer.start; | |
1187 } | |
1188 | |
491 | 1189 return NGX_AGAIN; |
1190 } | |
1191 | |
1192 } else { | |
1193 f->state = ngx_http_fastcgi_st_version; | |
1194 } | |
1195 | |
1196 continue; | |
1197 } | |
1198 | |
1199 | |
1200 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1201 | |
615 | 1202 f->fastcgi_stdout = 1; |
1203 | |
581 | 1204 start = u->buffer.pos; |
479 | 1205 |
581 | 1206 if (u->buffer.pos + f->length < u->buffer.last) { |
479 | 1207 |
1208 /* | |
581 | 1209 * set u->buffer.last to the end of the FastCGI record data |
479 | 1210 * for ngx_http_parse_header_line() |
1211 */ | |
1212 | |
581 | 1213 last = u->buffer.last; |
1214 u->buffer.last = u->buffer.pos + f->length; | |
479 | 1215 |
1216 } else { | |
1217 last = NULL; | |
1218 } | |
1219 | |
1220 for ( ;; ) { | |
1221 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1222 part_start = u->buffer.pos; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1223 |
2256 | 1224 rc = ngx_http_parse_header_line(r, &u->buffer, 1); |
479 | 1225 |
1226 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1227 "http fastcgi parser: %d", rc); | |
1228 | |
1229 if (rc == NGX_AGAIN) { | |
1230 break; | |
1231 } | |
1232 | |
1233 if (rc == NGX_OK) { | |
1234 | |
1235 /* a header line has been parsed successfully */ | |
1236 | |
509 | 1237 h = ngx_list_push(&u->headers_in.headers); |
501 | 1238 if (h == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1239 return NGX_ERROR; |
479 | 1240 } |
1241 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1242 if (f->split_parts && f->split_parts->nelts) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1243 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1244 part = f->split_parts->elts; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1245 size = u->buffer.pos - part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1246 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1247 for (i = 0; i < f->split_parts->nelts; i++) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1248 size += part[i].end - part[i].start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1249 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1250 |
2049 | 1251 p = ngx_pnalloc(r->pool, size); |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1252 if (p == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1253 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1254 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1255 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1256 buf.pos = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1257 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1258 for (i = 0; i < f->split_parts->nelts; i++) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1259 p = ngx_cpymem(p, part[i].start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1260 part[i].end - part[i].start); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1261 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1262 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1263 p = ngx_cpymem(p, part_start, u->buffer.pos - part_start); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1264 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1265 buf.last = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1266 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1267 f->split_parts->nelts = 0; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1268 |
2256 | 1269 rc = ngx_http_parse_header_line(r, &buf, 1); |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1270 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1271 h->key.len = r->header_name_end - r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1272 h->key.data = r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1273 h->key.data[h->key.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1274 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1275 h->value.len = r->header_end - r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1276 h->value.data = r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1277 h->value.data[h->value.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1278 |
2049 | 1279 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1280 if (h->lowcase_key == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1281 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1282 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1283 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1284 } else { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1285 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1286 h->key.len = r->header_name_end - r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1287 h->value.len = r->header_end - r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1288 |
2049 | 1289 h->key.data = ngx_pnalloc(r->pool, |
1290 h->key.len + 1 + h->value.len + 1 | |
1291 + h->key.len); | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1292 if (h->key.data == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1293 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1294 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1295 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1296 h->value.data = h->key.data + h->key.len + 1; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1297 h->lowcase_key = h->key.data + h->key.len + 1 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1298 + h->value.len + 1; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1299 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1300 ngx_cpystrn(h->key.data, r->header_name_start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1301 h->key.len + 1); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1302 ngx_cpystrn(h->value.data, r->header_start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1303 h->value.len + 1); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1304 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1305 |
509 | 1306 h->hash = r->header_hash; |
1307 | |
649 | 1308 if (h->key.len == r->lowcase_index) { |
1309 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1310 | |
1311 } else { | |
2135 | 1312 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
479 | 1313 } |
1314 | |
649 | 1315 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1316 h->lowcase_key, h->key.len); | |
1317 | |
1318 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1319 return NGX_ERROR; |
649 | 1320 } |
1321 | |
479 | 1322 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1323 "http fastcgi header: \"%V: %V\"", | |
1324 &h->key, &h->value); | |
1325 | |
615 | 1326 if (u->buffer.pos < u->buffer.last) { |
1327 continue; | |
1328 } | |
1329 | |
1330 /* the end of the FastCGI record */ | |
1331 | |
1332 break; | |
479 | 1333 } |
1334 | |
1335 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1336 | |
1337 /* a whole header has been parsed successfully */ | |
1338 | |
1339 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1340 "http fastcgi header done"); | |
1341 | |
509 | 1342 if (u->headers_in.status) { |
1343 status_line = &u->headers_in.status->value; | |
479 | 1344 |
1345 status = ngx_atoi(status_line->data, 3); | |
1346 | |
1347 if (status == NGX_ERROR) { | |
1698
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1348 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1349 "upstream sent invalid status \"%V\"", |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1350 status_line); |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1351 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
479 | 1352 } |
1353 | |
529 | 1354 u->headers_in.status_n = status; |
1355 u->headers_in.status_line = *status_line; | |
479 | 1356 |
2140
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1357 } else if (u->headers_in.location) { |
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1358 u->headers_in.status_n = 302; |
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1359 u->headers_in.status_line.len = |
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1360 sizeof("302 Moved Temporarily") - 1; |
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1361 u->headers_in.status_line.data = |
2223
005fc65f7ce7
style fix: remove tabs and trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
2140
diff
changeset
|
1362 (u_char *) "302 Moved Temporarily"; |
2140
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1363 |
479 | 1364 } else { |
529 | 1365 u->headers_in.status_n = 200; |
1366 u->headers_in.status_line.len = sizeof("200 OK") - 1; | |
1367 u->headers_in.status_line.data = (u_char *) "200 OK"; | |
479 | 1368 } |
1369 | |
2602 | 1370 if (u->state) { |
1371 u->state->status = u->headers_in.status_n; | |
479 | 1372 } |
1373 | |
1374 break; | |
1375 } | |
1376 | |
1377 /* there was error while a header line parsing */ | |
1378 | |
1379 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
619 | 1380 "upstream sent invalid header"); |
479 | 1381 |
1382 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1383 } | |
1384 | |
1385 if (last) { | |
581 | 1386 u->buffer.last = last; |
479 | 1387 } |
1388 | |
581 | 1389 f->length -= u->buffer.pos - start; |
479 | 1390 |
1391 if (f->length == 0) { | |
1392 if (f->padding) { | |
1393 f->state = ngx_http_fastcgi_st_padding; | |
1394 } else { | |
1395 f->state = ngx_http_fastcgi_st_version; | |
1396 } | |
1397 } | |
1398 | |
615 | 1399 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
1400 return NGX_OK; | |
1401 } | |
1402 | |
1274 | 1403 if (rc == NGX_OK) { |
1998
63c60504c0bf
fix error introduced in r1273 and r1275:
Igor Sysoev <igor@sysoev.ru>
parents:
1945
diff
changeset
|
1404 continue; |
615 | 1405 } |
1406 | |
1274 | 1407 /* rc == NGX_AGAIN */ |
1408 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1409 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1410 "upstream split a header line in FastCGI records"); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1411 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1412 if (f->split_parts == NULL) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1413 f->split_parts = ngx_array_create(r->pool, 1, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1414 sizeof(ngx_http_fastcgi_split_part_t)); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1415 if (f->split_parts == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1416 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1417 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1418 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1419 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1420 part = ngx_array_push(f->split_parts); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1421 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1422 part->start = part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1423 part->end = u->buffer.last; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1424 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1425 return NGX_AGAIN; |
479 | 1426 } |
1427 } | |
1428 | |
1429 | |
487 | 1430 static ngx_int_t |
1431 ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) | |
479 | 1432 { |
1433 ngx_int_t rc; | |
483 | 1434 ngx_buf_t *b, **prev; |
479 | 1435 ngx_str_t line; |
1436 ngx_chain_t *cl; | |
1437 ngx_http_request_t *r; | |
1438 ngx_http_fastcgi_ctx_t *f; | |
1439 | |
1440 if (buf->pos == buf->last) { | |
1441 return NGX_OK; | |
1442 } | |
1443 | |
1444 r = p->input_ctx; | |
1445 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1446 | |
1447 b = NULL; | |
483 | 1448 prev = &buf->shadow; |
479 | 1449 |
1450 f->pos = buf->pos; | |
1451 f->last = buf->last; | |
1452 | |
1453 for ( ;; ) { | |
1454 if (f->state < ngx_http_fastcgi_st_data) { | |
1455 | |
1456 rc = ngx_http_fastcgi_process_record(r, f); | |
1457 | |
1458 if (rc == NGX_AGAIN) { | |
1459 break; | |
1460 } | |
1461 | |
1462 if (rc == NGX_ERROR) { | |
1463 return NGX_ERROR; | |
1464 } | |
1465 | |
1466 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { | |
1467 f->state = ngx_http_fastcgi_st_version; | |
1468 p->upstream_done = 1; | |
1469 | |
1470 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1471 "http fastcgi closed stdout"); | |
1472 | |
1473 continue; | |
1474 } | |
1475 | |
1476 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | |
1477 f->state = ngx_http_fastcgi_st_version; | |
1478 p->upstream_done = 1; | |
1479 | |
1480 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1481 "http fastcgi sent end request"); | |
1482 | |
1483 break; | |
1484 } | |
1485 } | |
1486 | |
1487 | |
1488 if (f->state == ngx_http_fastcgi_st_padding) { | |
1489 | |
1490 if (f->pos + f->padding < f->last) { | |
1491 f->state = ngx_http_fastcgi_st_version; | |
1492 f->pos += f->padding; | |
1493 | |
1494 continue; | |
1495 } | |
1496 | |
1497 if (f->pos + f->padding == f->last) { | |
1498 f->state = ngx_http_fastcgi_st_version; | |
1499 | |
1500 break; | |
1501 } | |
1502 | |
1503 f->padding -= f->last - f->pos; | |
1504 | |
1505 break; | |
1506 } | |
1507 | |
1508 | |
1509 /* f->state == ngx_http_fastcgi_st_data */ | |
1510 | |
1511 if (f->type == NGX_HTTP_FASTCGI_STDERR) { | |
1512 | |
1513 if (f->length) { | |
639 | 1514 |
1515 if (f->pos == f->last) { | |
1516 break; | |
1517 } | |
1518 | |
479 | 1519 line.data = f->pos; |
1520 | |
1521 if (f->pos + f->length <= f->last) { | |
1522 line.len = f->length; | |
1523 f->pos += f->length; | |
491 | 1524 f->length = 0; |
1525 f->state = ngx_http_fastcgi_st_padding; | |
479 | 1526 |
577 | 1527 } else { |
479 | 1528 line.len = f->last - f->pos; |
1529 f->length -= f->last - f->pos; | |
1530 f->pos = f->last; | |
1531 } | |
1532 | |
491 | 1533 while (line.data[line.len - 1] == LF |
1534 || line.data[line.len - 1] == CR | |
1535 || line.data[line.len - 1] == '.' | |
1536 || line.data[line.len - 1] == ' ') | |
1537 { | |
1538 line.len--; | |
1539 } | |
479 | 1540 |
1541 ngx_log_error(NGX_LOG_ERR, p->log, 0, | |
491 | 1542 "FastCGI sent in stderr: \"%V\"", &line); |
479 | 1543 |
1544 if (f->pos == f->last) { | |
1545 break; | |
1546 } | |
491 | 1547 |
1548 } else { | |
1549 f->state = ngx_http_fastcgi_st_version; | |
479 | 1550 } |
1551 | |
1552 continue; | |
1553 } | |
1554 | |
1555 | |
1556 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1557 | |
639 | 1558 if (f->pos == f->last) { |
1559 break; | |
1560 } | |
1561 | |
479 | 1562 if (p->free) { |
1563 b = p->free->buf; | |
1564 p->free = p->free->next; | |
1565 | |
1566 } else { | |
501 | 1567 b = ngx_alloc_buf(p->pool); |
1568 if (b == NULL) { | |
479 | 1569 return NGX_ERROR; |
1570 } | |
1571 } | |
1572 | |
1573 ngx_memzero(b, sizeof(ngx_buf_t)); | |
1574 | |
1575 b->pos = f->pos; | |
483 | 1576 b->start = buf->start; |
1577 b->end = buf->end; | |
479 | 1578 b->tag = p->tag; |
1579 b->temporary = 1; | |
1580 b->recycled = 1; | |
483 | 1581 |
1582 *prev = b; | |
1583 prev = &b->shadow; | |
479 | 1584 |
501 | 1585 cl = ngx_alloc_chain_link(p->pool); |
1586 if (cl == NULL) { | |
479 | 1587 return NGX_ERROR; |
1588 } | |
1589 | |
1590 cl->buf = b; | |
1591 cl->next = NULL; | |
1592 | |
501 | 1593 if (p->in) { |
1594 *p->last_in = cl; | |
1595 } else { | |
1596 p->in = cl; | |
1597 } | |
1598 p->last_in = &cl->next; | |
1599 | |
1600 | |
483 | 1601 /* STUB */ b->num = buf->num; |
1602 | |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1603 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1604 "input buf #%d %p", b->num, b->pos); |
479 | 1605 |
1606 if (f->pos + f->length < f->last) { | |
1607 | |
1608 if (f->padding) { | |
1609 f->state = ngx_http_fastcgi_st_padding; | |
1610 } else { | |
1611 f->state = ngx_http_fastcgi_st_version; | |
1612 } | |
1613 | |
1614 f->pos += f->length; | |
1615 b->last = f->pos; | |
1616 | |
1617 continue; | |
1618 } | |
1619 | |
1620 if (f->pos + f->length == f->last) { | |
1621 | |
1622 if (f->padding) { | |
1623 f->state = ngx_http_fastcgi_st_padding; | |
1624 } else { | |
1625 f->state = ngx_http_fastcgi_st_version; | |
1626 } | |
1627 | |
1628 b->last = f->last; | |
1629 | |
1630 break; | |
1631 } | |
1632 | |
1633 f->length -= f->last - f->pos; | |
1634 | |
1635 b->last = f->last; | |
1636 | |
1637 break; | |
1638 | |
1639 } | |
1640 | |
1641 if (b) { | |
483 | 1642 b->shadow = buf; |
479 | 1643 b->last_shadow = 1; |
483 | 1644 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1645 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1646 "input buf %p %z", b->pos, b->last - b->pos); |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1647 |
483 | 1648 return NGX_OK; |
1649 } | |
1650 | |
1651 /* there is no data record in the buf, add it to free chain */ | |
1652 | |
1653 if (ngx_event_pipe_add_free_buf(p, buf) != NGX_OK) { | |
1654 return NGX_ERROR; | |
479 | 1655 } |
1656 | |
1657 return NGX_OK; | |
1658 } | |
1659 | |
1660 | |
487 | 1661 static ngx_int_t |
1662 ngx_http_fastcgi_process_record(ngx_http_request_t *r, | |
1663 ngx_http_fastcgi_ctx_t *f) | |
479 | 1664 { |
1665 u_char ch, *p; | |
1666 ngx_http_fastcgi_state_e state; | |
1667 | |
1668 state = f->state; | |
1669 | |
1670 for (p = f->pos; p < f->last; p++) { | |
1671 | |
1672 ch = *p; | |
1673 | |
1674 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1675 "http fastcgi record byte: %02Xd", ch); | |
1676 | |
1677 switch (state) { | |
1678 | |
1679 case ngx_http_fastcgi_st_version: | |
1680 if (ch != 1) { | |
1681 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1682 "upstream sent unsupported FastCGI " | |
1683 "protocol version: %d", ch); | |
1684 return NGX_ERROR; | |
1685 } | |
1686 state = ngx_http_fastcgi_st_type; | |
1687 break; | |
1688 | |
1689 case ngx_http_fastcgi_st_type: | |
1690 switch (ch) { | |
1691 case NGX_HTTP_FASTCGI_STDOUT: | |
1692 case NGX_HTTP_FASTCGI_STDERR: | |
1693 case NGX_HTTP_FASTCGI_END_REQUEST: | |
1694 f->type = (ngx_uint_t) ch; | |
1695 break; | |
1696 default: | |
1697 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1698 "upstream sent invalid FastCGI " | |
1699 "record type: %d", ch); | |
1700 return NGX_ERROR; | |
1701 | |
1702 } | |
1703 state = ngx_http_fastcgi_st_request_id_hi; | |
1704 break; | |
1705 | |
1706 /* we support the single request per connection */ | |
1707 | |
1708 case ngx_http_fastcgi_st_request_id_hi: | |
1709 if (ch != 0) { | |
1710 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1711 "upstream sent unexpected FastCGI " | |
1712 "request id high byte: %d", ch); | |
1713 return NGX_ERROR; | |
1714 } | |
1715 state = ngx_http_fastcgi_st_request_id_lo; | |
1716 break; | |
1717 | |
1718 case ngx_http_fastcgi_st_request_id_lo: | |
1719 if (ch != 1) { | |
1720 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1721 "upstream sent unexpected FastCGI " | |
1722 "request id low byte: %d", ch); | |
1723 return NGX_ERROR; | |
1724 } | |
1725 state = ngx_http_fastcgi_st_content_length_hi; | |
1726 break; | |
1727 | |
1728 case ngx_http_fastcgi_st_content_length_hi: | |
1729 f->length = ch << 8; | |
1730 state = ngx_http_fastcgi_st_content_length_lo; | |
1731 break; | |
1732 | |
1733 case ngx_http_fastcgi_st_content_length_lo: | |
1734 f->length |= (size_t) ch; | |
1735 state = ngx_http_fastcgi_st_padding_length; | |
1736 break; | |
1737 | |
1738 case ngx_http_fastcgi_st_padding_length: | |
1739 f->padding = (size_t) ch; | |
1740 state = ngx_http_fastcgi_st_reserved; | |
1741 break; | |
1742 | |
1743 case ngx_http_fastcgi_st_reserved: | |
1744 state = ngx_http_fastcgi_st_data; | |
1745 | |
1746 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1747 "http fastcgi record length: %z", f->length); | |
1748 | |
1749 f->pos = p + 1; | |
1750 f->state = state; | |
1751 | |
1752 return NGX_OK; | |
1753 | |
1754 /* suppress warning */ | |
1755 case ngx_http_fastcgi_st_data: | |
1756 case ngx_http_fastcgi_st_padding: | |
1757 break; | |
1758 } | |
1759 } | |
1760 | |
1761 f->state = state; | |
1762 | |
1763 return NGX_AGAIN; | |
1764 } | |
1765 | |
1766 | |
487 | 1767 static void |
1768 ngx_http_fastcgi_abort_request(ngx_http_request_t *r) | |
479 | 1769 { |
1770 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1771 "abort http fastcgi request"); | |
1772 | |
1773 return; | |
1774 } | |
1775 | |
1776 | |
487 | 1777 static void |
1778 ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
479 | 1779 { |
1780 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1781 "finalize http fastcgi request"); | |
1782 | |
1783 return; | |
1784 } | |
1785 | |
1786 | |
509 | 1787 static ngx_int_t |
1788 ngx_http_fastcgi_add_variables(ngx_conf_t *cf) | |
479 | 1789 { |
2443 | 1790 ngx_http_variable_t *var, *v; |
1791 | |
1792 for (v = ngx_http_fastcgi_vars; v->name.len; v++) { | |
1793 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
1794 if (var == NULL) { | |
1795 return NGX_ERROR; | |
1796 } | |
1797 | |
1798 var->get_handler = v->get_handler; | |
1799 var->data = v->data; | |
479 | 1800 } |
1801 | |
509 | 1802 return NGX_OK; |
479 | 1803 } |
1804 | |
1805 | |
487 | 1806 static void * |
1807 ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) | |
479 | 1808 { |
1809 ngx_http_fastcgi_loc_conf_t *conf; | |
1810 | |
501 | 1811 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)); |
1812 if (conf == NULL) { | |
479 | 1813 return NGX_CONF_ERROR; |
1814 } | |
1815 | |
1816 /* | |
1817 * set by ngx_pcalloc(): | |
1818 * | |
1819 * conf->upstream.bufs.num = 0; | |
1820 * conf->upstream.next_upstream = 0; | |
2602 | 1821 * conf->upstream.use_stale_cache = 0; |
479 | 1822 * conf->upstream.temp_path = NULL; |
649 | 1823 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
509 | 1824 * conf->upstream.uri = { 0, NULL }; |
1825 * conf->upstream.location = NULL; | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1826 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1827 * conf->upstream.store_values = NULL; |
509 | 1828 * |
479 | 1829 * conf->index.len = 0; |
1830 * conf->index.data = NULL; | |
1831 */ | |
1832 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1833 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1834 conf->upstream.store_access = NGX_CONF_UNSET_UINT; |
581 | 1835 conf->upstream.buffering = NGX_CONF_UNSET; |
629 | 1836 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; |
581 | 1837 |
479 | 1838 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
1839 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
507 | 1840 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC; |
1841 | |
479 | 1842 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; |
581 | 1843 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; |
529 | 1844 |
1845 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 1846 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 1847 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 1848 |
1849 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
1850 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
1851 | |
2602 | 1852 #if (NGX_HTTP_CACHE) |
1853 conf->upstream.cache = NGX_CONF_UNSET_PTR; | |
1854 conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT; | |
1855 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; | |
1856 #endif | |
1857 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1858 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1859 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1860 |
657 | 1861 conf->upstream.intercept_errors = NGX_CONF_UNSET; |
479 | 1862 |
1863 /* "fastcgi_cyclic_temp_file" is disabled */ | |
1864 conf->upstream.cyclic_temp_file = 0; | |
1865 | |
1452
cd586e963db0
change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr
Igor Sysoev <igor@sysoev.ru>
parents:
1295
diff
changeset
|
1866 conf->catch_stderr = NGX_CONF_UNSET_PTR; |
cd586e963db0
change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr
Igor Sysoev <igor@sysoev.ru>
parents:
1295
diff
changeset
|
1867 |
479 | 1868 return conf; |
1869 } | |
1870 | |
1871 | |
487 | 1872 static char * |
1873 ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
479 | 1874 { |
1875 ngx_http_fastcgi_loc_conf_t *prev = parent; | |
1876 ngx_http_fastcgi_loc_conf_t *conf = child; | |
1877 | |
509 | 1878 u_char *p; |
1879 size_t size; | |
1880 uintptr_t *code; | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1881 ngx_uint_t i; |
649 | 1882 ngx_keyval_t *src; |
1883 ngx_hash_init_t hash; | |
509 | 1884 ngx_http_script_compile_t sc; |
1885 ngx_http_script_copy_code_t *copy; | |
479 | 1886 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1887 if (conf->upstream.store != 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1888 ngx_conf_merge_value(conf->upstream.store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1889 prev->upstream.store, 0); |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1890 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1891 if (conf->upstream.store_lengths == NULL) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1892 conf->upstream.store_lengths = prev->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1893 conf->upstream.store_values = prev->upstream.store_values; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1894 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1895 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1896 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1897 ngx_conf_merge_uint_value(conf->upstream.store_access, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1898 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
1899 |
581 | 1900 ngx_conf_merge_value(conf->upstream.buffering, |
1901 prev->upstream.buffering, 1); | |
1902 | |
629 | 1903 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
1904 prev->upstream.ignore_client_abort, 0); | |
1905 | |
479 | 1906 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
1907 prev->upstream.connect_timeout, 60000); | |
507 | 1908 |
479 | 1909 ngx_conf_merge_msec_value(conf->upstream.send_timeout, |
1910 prev->upstream.send_timeout, 60000); | |
1911 | |
1912 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
1913 prev->upstream.read_timeout, 60000); | |
1914 | |
507 | 1915 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
1916 prev->upstream.send_lowat, 0); | |
479 | 1917 |
581 | 1918 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
1919 prev->upstream.buffer_size, | |
479 | 1920 (size_t) ngx_pagesize); |
1921 | |
507 | 1922 |
479 | 1923 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
1924 8, ngx_pagesize); | |
1925 | |
1926 if (conf->upstream.bufs.num < 2) { | |
1927 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1928 "there must be at least 2 \"fastcgi_buffers\""); | |
1929 return NGX_CONF_ERROR; | |
1930 } | |
1931 | |
1932 | |
581 | 1933 size = conf->upstream.buffer_size; |
479 | 1934 if (size < conf->upstream.bufs.size) { |
1935 size = conf->upstream.bufs.size; | |
1936 } | |
1937 | |
1938 | |
529 | 1939 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
1940 prev->upstream.busy_buffers_size_conf, | |
479 | 1941 NGX_CONF_UNSET_SIZE); |
1942 | |
529 | 1943 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1944 conf->upstream.busy_buffers_size = 2 * size; |
529 | 1945 } else { |
1946 conf->upstream.busy_buffers_size = | |
1947 conf->upstream.busy_buffers_size_conf; | |
1948 } | |
479 | 1949 |
529 | 1950 if (conf->upstream.busy_buffers_size < size) { |
479 | 1951 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1952 "\"fastcgi_busy_buffers_size\" must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
1953 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1954 "one of the \"fastcgi_buffers\""); |
1955 | |
1956 return NGX_CONF_ERROR; | |
529 | 1957 } |
479 | 1958 |
529 | 1959 if (conf->upstream.busy_buffers_size |
1960 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
479 | 1961 { |
1962 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1963 "\"fastcgi_busy_buffers_size\" must be less than " | |
1964 "the size of all \"fastcgi_buffers\" minus one buffer"); | |
1965 | |
1966 return NGX_CONF_ERROR; | |
1967 } | |
1968 | |
1969 | |
529 | 1970 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
1971 prev->upstream.temp_file_write_size_conf, | |
479 | 1972 NGX_CONF_UNSET_SIZE); |
1973 | |
529 | 1974 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1975 conf->upstream.temp_file_write_size = 2 * size; |
529 | 1976 } else { |
1977 conf->upstream.temp_file_write_size = | |
1978 conf->upstream.temp_file_write_size_conf; | |
1979 } | |
479 | 1980 |
529 | 1981 if (conf->upstream.temp_file_write_size < size) { |
479 | 1982 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1983 "\"fastcgi_temp_file_write_size\" must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
1984 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1985 "one of the \"fastcgi_buffers\""); |
1986 | |
1987 return NGX_CONF_ERROR; | |
1988 } | |
1989 | |
1990 | |
529 | 1991 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
1992 prev->upstream.max_temp_file_size_conf, | |
479 | 1993 NGX_CONF_UNSET_SIZE); |
1994 | |
529 | 1995 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1996 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 1997 } else { |
1998 conf->upstream.max_temp_file_size = | |
1999 conf->upstream.max_temp_file_size_conf; | |
2000 } | |
479 | 2001 |
529 | 2002 if (conf->upstream.max_temp_file_size != 0 |
2003 && conf->upstream.max_temp_file_size < size) | |
479 | 2004 { |
2005 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2006 "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " | |
2007 "the temporary files usage or must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
2008 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 2009 "one of the \"fastcgi_buffers\""); |
2010 | |
2011 return NGX_CONF_ERROR; | |
2012 } | |
2013 | |
2014 | |
2015 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, | |
487 | 2016 prev->upstream.next_upstream, |
2017 (NGX_CONF_BITMASK_SET | |
2018 |NGX_HTTP_UPSTREAM_FT_ERROR | |
2019 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
479 | 2020 |
665 | 2021 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
2022 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
2023 |NGX_HTTP_UPSTREAM_FT_OFF; | |
2024 } | |
2025 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2026 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, |
479 | 2027 prev->upstream.temp_path, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2028 &ngx_http_fastcgi_temp_path) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2029 != NGX_OK) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2030 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2031 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2032 } |
479 | 2033 |
2602 | 2034 #if (NGX_HTTP_CACHE) |
2035 | |
2036 ngx_conf_merge_ptr_value(conf->upstream.cache, | |
2037 prev->upstream.cache, NULL); | |
2038 | |
2039 if (conf->upstream.cache && conf->upstream.cache->data == NULL) { | |
2040 ngx_shm_zone_t *shm_zone; | |
2041 | |
2042 shm_zone = conf->upstream.cache; | |
2043 | |
2044 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2045 "\"fastcgi_cache\" zone \"%V\" is unknown", | |
2046 &shm_zone->name); | |
2047 | |
2048 return NGX_CONF_ERROR; | |
2049 } | |
2050 | |
2051 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses, | |
2052 prev->upstream.cache_min_uses, 1); | |
2053 | |
2054 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale, | |
2055 prev->upstream.cache_use_stale, | |
2056 (NGX_CONF_BITMASK_SET | |
2057 |NGX_HTTP_UPSTREAM_FT_OFF)); | |
2058 | |
2059 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) { | |
2060 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET | |
2061 |NGX_HTTP_UPSTREAM_FT_OFF; | |
2062 } | |
2063 | |
2064 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, | |
2065 prev->upstream.cache_valid, NULL); | |
2066 | |
2661 | 2067 if (conf->cache_key.value.data == NULL) { |
2068 conf->cache_key = prev->cache_key; | |
2069 } | |
2070 | |
2602 | 2071 #endif |
2072 | |
509 | 2073 ngx_conf_merge_value(conf->upstream.pass_request_headers, |
2074 prev->upstream.pass_request_headers, 1); | |
2075 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
2076 prev->upstream.pass_request_body, 1); | |
2077 | |
657 | 2078 ngx_conf_merge_value(conf->upstream.intercept_errors, |
2079 prev->upstream.intercept_errors, 0); | |
509 | 2080 |
1228 | 2081 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL); |
2082 | |
507 | 2083 |
479 | 2084 ngx_conf_merge_str_value(conf->index, prev->index, ""); |
2085 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2086 hash.max_size = 512; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2087 hash.bucket_size = ngx_align(64, ngx_cacheline_size); |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2088 hash.name = "fastcgi_hide_headers_hash"; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2089 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2090 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2091 &prev->upstream, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2092 ngx_http_fastcgi_hide_headers, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2093 &hash) |
649 | 2094 != NGX_OK) |
2095 { | |
2096 return NGX_CONF_ERROR; | |
2097 } | |
2098 | |
884 | 2099 if (conf->upstream.upstream == NULL) { |
2100 conf->upstream.upstream = prev->upstream.upstream; | |
507 | 2101 } |
2102 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2103 if (conf->fastcgi_lengths == NULL) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2104 conf->fastcgi_lengths = prev->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2105 conf->fastcgi_values = prev->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2106 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2107 |
2443 | 2108 #if (NGX_PCRE) |
2109 if (conf->split_regex == NULL) { | |
2110 conf->split_regex = prev->split_regex; | |
2111 conf->split_name = prev->split_name; | |
2112 } | |
2113 #endif | |
2114 | |
509 | 2115 if (conf->params_source == NULL) { |
573 | 2116 conf->flushes = prev->flushes; |
509 | 2117 conf->params_len = prev->params_len; |
2118 conf->params = prev->params; | |
573 | 2119 conf->params_source = prev->params_source; |
509 | 2120 |
2121 if (conf->params_source == NULL) { | |
2122 return NGX_CONF_OK; | |
2123 } | |
2124 } | |
2125 | |
2126 conf->params_len = ngx_array_create(cf->pool, 64, 1); | |
2127 if (conf->params_len == NULL) { | |
2128 return NGX_CONF_ERROR; | |
2129 } | |
573 | 2130 |
509 | 2131 conf->params = ngx_array_create(cf->pool, 512, 1); |
2132 if (conf->params == NULL) { | |
2133 return NGX_CONF_ERROR; | |
2134 } | |
2135 | |
2136 src = conf->params_source->elts; | |
2137 for (i = 0; i < conf->params_source->nelts; i++) { | |
2138 | |
2139 if (ngx_http_script_variables_count(&src[i].value) == 0) { | |
2140 copy = ngx_array_push_n(conf->params_len, | |
2141 sizeof(ngx_http_script_copy_code_t)); | |
2142 if (copy == NULL) { | |
2143 return NGX_CONF_ERROR; | |
2144 } | |
2145 | |
2146 copy->code = (ngx_http_script_code_pt) | |
2147 ngx_http_script_copy_len_code; | |
2148 copy->len = src[i].key.len; | |
2149 | |
2150 | |
2151 copy = ngx_array_push_n(conf->params_len, | |
2152 sizeof(ngx_http_script_copy_code_t)); | |
2153 if (copy == NULL) { | |
2154 return NGX_CONF_ERROR; | |
2155 } | |
2156 | |
2157 copy->code = (ngx_http_script_code_pt) | |
2158 ngx_http_script_copy_len_code; | |
2159 copy->len = src[i].value.len; | |
2160 | |
2161 | |
2162 size = (sizeof(ngx_http_script_copy_code_t) | |
2163 + src[i].key.len + src[i].value.len | |
2164 + sizeof(uintptr_t) - 1) | |
2165 & ~(sizeof(uintptr_t) - 1); | |
2166 | |
2167 copy = ngx_array_push_n(conf->params, size); | |
2168 if (copy == NULL) { | |
2169 return NGX_CONF_ERROR; | |
2170 } | |
577 | 2171 |
509 | 2172 copy->code = ngx_http_script_copy_code; |
2173 copy->len = src[i].key.len + src[i].value.len; | |
2174 | |
2175 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
2176 | |
2177 p = ngx_cpymem(p, src[i].key.data, src[i].key.len); | |
2178 ngx_memcpy(p, src[i].value.data, src[i].value.len); | |
2179 | |
2180 } else { | |
2181 copy = ngx_array_push_n(conf->params_len, | |
2182 sizeof(ngx_http_script_copy_code_t)); | |
2183 if (copy == NULL) { | |
2184 return NGX_CONF_ERROR; | |
2185 } | |
2186 | |
2187 copy->code = (ngx_http_script_code_pt) | |
2188 ngx_http_script_copy_len_code; | |
2189 copy->len = src[i].key.len; | |
2190 | |
2191 | |
2192 size = (sizeof(ngx_http_script_copy_code_t) | |
2193 + src[i].key.len + sizeof(uintptr_t) - 1) | |
2194 & ~(sizeof(uintptr_t) - 1); | |
2195 | |
2196 copy = ngx_array_push_n(conf->params, size); | |
2197 if (copy == NULL) { | |
2198 return NGX_CONF_ERROR; | |
2199 } | |
577 | 2200 |
509 | 2201 copy->code = ngx_http_script_copy_code; |
2202 copy->len = src[i].key.len; | |
2203 | |
2204 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
2205 ngx_memcpy(p, src[i].key.data, src[i].key.len); | |
2206 | |
2207 | |
2208 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
2209 | |
2210 sc.cf = cf; | |
2211 sc.source = &src[i].value; | |
573 | 2212 sc.flushes = &conf->flushes; |
509 | 2213 sc.lengths = &conf->params_len; |
2214 sc.values = &conf->params; | |
2215 | |
2216 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
2217 return NGX_CONF_ERROR; | |
2218 } | |
2219 } | |
2220 | |
2221 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
2222 if (code == NULL) { | |
2223 return NGX_CONF_ERROR; | |
2224 } | |
2225 | |
2226 *code = (uintptr_t) NULL; | |
2227 | |
2228 | |
2229 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); | |
2230 if (code == NULL) { | |
2231 return NGX_CONF_ERROR; | |
2232 } | |
2233 | |
2234 *code = (uintptr_t) NULL; | |
2235 } | |
2236 | |
2237 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
2238 if (code == NULL) { | |
2239 return NGX_CONF_ERROR; | |
2240 } | |
2241 | |
2242 *code = (uintptr_t) NULL; | |
2243 | |
479 | 2244 return NGX_CONF_OK; |
2245 } | |
509 | 2246 |
2247 | |
573 | 2248 static ngx_int_t |
2249 ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, | |
2250 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 2251 { |
2252 u_char *p; | |
2443 | 2253 ngx_http_fastcgi_ctx_t *f; |
509 | 2254 ngx_http_fastcgi_loc_conf_t *flcf; |
2255 | |
2443 | 2256 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
2257 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2258 f = ngx_http_fastcgi_split(r, flcf); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2259 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2260 if (f == NULL) { |
2443 | 2261 return NGX_ERROR; |
2262 } | |
2263 | |
2264 if (f->script_name.len == 0 | |
2265 || f->script_name.data[f->script_name.len - 1] != '/') | |
2266 { | |
2267 v->len = f->script_name.len; | |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2268 v->valid = 1; |
1565 | 2269 v->no_cacheable = 0; |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2270 v->not_found = 0; |
2443 | 2271 v->data = f->script_name.data; |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2272 |
573 | 2273 return NGX_OK; |
509 | 2274 } |
2275 | |
2443 | 2276 v->len = f->script_name.len + flcf->index.len; |
2277 | |
2278 v->data = ngx_pnalloc(r->pool, v->len); | |
2279 if (v->data == NULL) { | |
2280 return NGX_ERROR; | |
2281 } | |
2282 | |
2283 p = ngx_copy(v->data, f->script_name.data, f->script_name.len); | |
2284 ngx_memcpy(p, flcf->index.data, flcf->index.len); | |
2285 | |
573 | 2286 return NGX_OK; |
509 | 2287 } |
2288 | |
2289 | |
2443 | 2290 static ngx_int_t |
2291 ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, | |
2292 ngx_http_variable_value_t *v, uintptr_t data) | |
2293 { | |
2294 ngx_http_fastcgi_ctx_t *f; | |
2295 ngx_http_fastcgi_loc_conf_t *flcf; | |
2296 | |
2297 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); | |
2298 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2299 f = ngx_http_fastcgi_split(r, flcf); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2300 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2301 if (f == NULL) { |
2443 | 2302 return NGX_ERROR; |
2303 } | |
2304 | |
2305 v->len = f->path_info.len; | |
2306 v->valid = 1; | |
2307 v->no_cacheable = 0; | |
2308 v->not_found = 0; | |
2309 v->data = f->path_info.data; | |
2310 | |
2311 return NGX_OK; | |
2312 } | |
2313 | |
2314 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2315 static ngx_http_fastcgi_ctx_t * |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2316 ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf) |
2443 | 2317 { |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2318 ngx_http_fastcgi_ctx_t *f; |
2443 | 2319 #if (NGX_PCRE) |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2320 ngx_int_t n; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2321 int captures[(1 + 2) * 3]; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2322 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2323 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2324 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2325 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2326 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2327 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2328 return NULL; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2329 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2330 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2331 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2332 } |
2443 | 2333 |
2334 if (f->script_name.len) { | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2335 return f; |
2443 | 2336 } |
2337 | |
2338 if (flcf->split_regex == NULL) { | |
2339 f->script_name = r->uri; | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2340 return f; |
2443 | 2341 } |
2342 | |
2343 n = ngx_regex_exec(flcf->split_regex, &r->uri, captures, (1 + 2) * 3); | |
2344 | |
2345 if (n == NGX_REGEX_NO_MATCHED) { | |
2346 f->script_name = r->uri; | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2347 return f; |
2443 | 2348 } |
2349 | |
2350 if (n < 0) { | |
2351 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
2352 ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"", | |
2353 n, &r->uri, &flcf->split_name); | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2354 return NULL; |
2443 | 2355 } |
2356 | |
2357 /* match */ | |
2358 | |
2359 f->script_name.len = captures[3] - captures[2]; | |
2360 f->script_name.data = r->uri.data; | |
2361 | |
2362 f->path_info.len = captures[5] - captures[4]; | |
2363 f->path_info.data = r->uri.data + f->script_name.len; | |
2364 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2365 return f; |
2443 | 2366 |
2367 #else | |
2368 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2369 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2370 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2371 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2372 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2373 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2374 return NULL; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2375 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2376 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2377 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2378 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2379 |
2443 | 2380 f->script_name = r->uri; |
2381 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2382 return f; |
2443 | 2383 |
2384 #endif | |
2385 } | |
2386 | |
2387 | |
509 | 2388 static char * |
2389 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2390 { | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2391 ngx_http_fastcgi_loc_conf_t *flcf = conf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2392 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2393 ngx_url_t u; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2394 ngx_str_t *value, *url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2395 ngx_uint_t n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2396 ngx_http_core_loc_conf_t *clcf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2397 ngx_http_script_compile_t sc; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2398 |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2390
diff
changeset
|
2399 if (flcf->upstream.upstream || flcf->fastcgi_lengths) { |
555 | 2400 return "is duplicate"; |
2401 } | |
2402 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2403 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2404 clcf->handler = ngx_http_fastcgi_handler; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2405 |
509 | 2406 value = cf->args->elts; |
2407 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2408 url = &value[1]; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2409 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2410 n = ngx_http_script_variables_count(url); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2411 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2412 if (n) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2413 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2414 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2415 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2416 sc.cf = cf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2417 sc.source = url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2418 sc.lengths = &flcf->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2419 sc.values = &flcf->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2420 sc.variables = n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2421 sc.complete_lengths = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2422 sc.complete_values = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2423 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2424 if (ngx_http_script_compile(&sc) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2425 return NGX_CONF_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2426 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2427 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2428 return NGX_CONF_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2429 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2430 |
651 | 2431 ngx_memzero(&u, sizeof(ngx_url_t)); |
2432 | |
2433 u.url = value[1]; | |
884 | 2434 u.no_resolve = 1; |
2435 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2436 flcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2437 if (flcf->upstream.upstream == NULL) { |
509 | 2438 return NGX_CONF_ERROR; |
2439 } | |
2440 | |
2441 if (clcf->name.data[clcf->name.len - 1] == '/') { | |
2442 clcf->auto_redirect = 1; | |
2443 } | |
2444 | |
2445 return NGX_CONF_OK; | |
2446 } | |
2447 | |
2448 | |
2449 static char * | |
2443 | 2450 ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
2451 { | |
2452 #if (NGX_PCRE) | |
2453 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2454 | |
2455 ngx_int_t n; | |
2456 ngx_str_t *value, err; | |
2457 u_char errstr[NGX_MAX_CONF_ERRSTR]; | |
2458 | |
2459 value = cf->args->elts; | |
2460 | |
2461 flcf->split_name = value[1]; | |
2462 | |
2463 err.len = NGX_MAX_CONF_ERRSTR; | |
2464 err.data = errstr; | |
2465 | |
2466 flcf->split_regex = ngx_regex_compile(&value[1], 0, cf->pool, &err); | |
2467 | |
2468 if (flcf->split_regex == NULL) { | |
2469 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", err.data); | |
2470 return NGX_CONF_ERROR; | |
2471 } | |
2472 | |
2473 n = ngx_regex_capture_count(flcf->split_regex); | |
2474 | |
2475 if (n < 0) { | |
2476 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2477 ngx_regex_capture_count_n " failed for " | |
2478 "pattern \"%V\"", &value[1]); | |
2479 return NGX_CONF_ERROR; | |
2480 } | |
2481 | |
2482 if (n != 2) { | |
2483 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2484 "pattern \"%V\" must have 2 captures", &value[1]); | |
2485 return NGX_CONF_ERROR; | |
2486 } | |
2487 | |
2488 return NGX_CONF_OK; | |
2489 | |
2490 #else | |
2491 | |
2492 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2493 "\"%V\" requires PCRE library", &cmd->name); | |
2494 return NGX_CONF_ERROR; | |
2495 | |
2496 #endif | |
2497 } | |
2498 | |
2499 | |
2500 static char * | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2501 ngx_http_fastcgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2502 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2503 ngx_http_fastcgi_loc_conf_t *flcf = conf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2504 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2505 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2506 ngx_http_script_compile_t sc; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2507 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2508 if (flcf->upstream.store != NGX_CONF_UNSET || flcf->upstream.store_lengths) |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2509 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2510 return "is duplicate"; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2511 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2512 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2513 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2514 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2515 if (ngx_strcmp(value[1].data, "on") == 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2516 flcf->upstream.store = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2517 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2518 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2519 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2520 if (ngx_strcmp(value[1].data, "off") == 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2521 flcf->upstream.store = 0; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2522 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2523 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2524 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2525 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2526 value[1].len++; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2527 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2528 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2529 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2530 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2531 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2532 sc.lengths = &flcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2533 sc.values = &flcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
2534 sc.variables = ngx_http_script_variables_count(&value[1]); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2535 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2536 sc.complete_values = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2537 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2538 if (ngx_http_script_compile(&sc) != NGX_OK) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2539 return NGX_CONF_ERROR; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2540 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2541 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2542 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2543 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2544 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2545 |
2602 | 2546 #if (NGX_HTTP_CACHE) |
2547 | |
2548 static char * | |
2549 ngx_http_fastcgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2550 { | |
2551 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2552 | |
2553 ngx_str_t *value; | |
2554 | |
2555 value = cf->args->elts; | |
2556 | |
2557 if (flcf->upstream.cache != NGX_CONF_UNSET_PTR) { | |
2558 return "is duplicate"; | |
2559 } | |
2560 | |
2561 if (ngx_strcmp(value[1].data, "off") == 0) { | |
2562 flcf->upstream.cache = NULL; | |
2563 return NGX_CONF_OK; | |
2564 } | |
2565 | |
2566 flcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, | |
2567 &ngx_http_fastcgi_module); | |
2568 if (flcf->upstream.cache == NULL) { | |
2569 return NGX_CONF_ERROR; | |
2570 } | |
2571 | |
2572 return NGX_CONF_OK; | |
2573 } | |
2574 | |
2575 | |
2576 static char * | |
2577 ngx_http_fastcgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2578 { | |
2579 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2580 | |
2581 ngx_str_t *value; | |
2582 ngx_http_compile_complex_value_t ccv; | |
2583 | |
2584 value = cf->args->elts; | |
2585 | |
2586 if (flcf->cache_key.value.len) { | |
2587 return "is duplicate"; | |
2588 } | |
2589 | |
2590 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
2591 | |
2592 ccv.cf = cf; | |
2593 ccv.value = &value[1]; | |
2594 ccv.complex_value = &flcf->cache_key; | |
2595 | |
2596 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
2597 return NGX_CONF_ERROR; | |
2598 } | |
2599 | |
2600 return NGX_CONF_OK; | |
2601 } | |
2602 | |
2603 #endif | |
2604 | |
2605 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2606 static char * |
509 | 2607 ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data) |
2608 { | |
2609 #if (NGX_FREEBSD) | |
2610 ssize_t *np = data; | |
2611 | |
673 | 2612 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
509 | 2613 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2614 "\"fastcgi_send_lowat\" must be less than %d " | |
2615 "(sysctl net.inet.tcp.sendspace)", | |
2616 ngx_freebsd_net_inet_tcp_sendspace); | |
2617 | |
2618 return NGX_CONF_ERROR; | |
2619 } | |
2620 | |
2621 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
2622 ssize_t *np = data; | |
2623 | |
2624 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
2625 "\"fastcgi_send_lowat\" is not supported, ignored"); | |
2626 | |
2627 *np = 0; | |
2628 | |
2629 #endif | |
2630 | |
2631 return NGX_CONF_OK; | |
2632 } | |
884 | 2633 |
2634 | |
2635 static char * | |
2636 ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf, | |
2637 ngx_command_t *cmd, void *conf) | |
2638 { | |
2639 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2640 "\"fastcgi_upstream_max_fails\" is not supported, " | |
2641 "use the \"max_fails\" parameter of the \"server\" directive ", | |
2642 "inside the \"upstream\" block"); | |
2643 | |
2644 return NGX_CONF_ERROR; | |
2645 } | |
2646 | |
2647 | |
2648 static char * | |
2649 ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf, | |
2650 ngx_command_t *cmd, void *conf) | |
2651 { | |
2652 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2653 "\"fastcgi_upstream_fail_timeout\" is not supported, " | |
2654 "use the \"fail_timeout\" parameter of the \"server\" directive ", | |
2655 "inside the \"upstream\" block"); | |
2656 | |
2657 return NGX_CONF_ERROR; | |
2658 } |