50
|
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 #include <nginx.h>
|
|
11
|
|
12
|
|
13 typedef struct {
|
200
|
14 ngx_http_upstream_conf_t upstream;
|
|
15
|
|
16 ngx_str_t index;
|
|
17
|
|
18 ngx_array_t *flushes;
|
|
19 ngx_array_t *params_len;
|
|
20 ngx_array_t *params;
|
|
21 ngx_array_t *params_source;
|
306
|
22 ngx_array_t *catch_stderr;
|
50
|
23 } ngx_http_fastcgi_loc_conf_t;
|
|
24
|
|
25
|
|
26 typedef enum {
|
|
27 ngx_http_fastcgi_st_version = 0,
|
|
28 ngx_http_fastcgi_st_type,
|
|
29 ngx_http_fastcgi_st_request_id_hi,
|
|
30 ngx_http_fastcgi_st_request_id_lo,
|
|
31 ngx_http_fastcgi_st_content_length_hi,
|
|
32 ngx_http_fastcgi_st_content_length_lo,
|
|
33 ngx_http_fastcgi_st_padding_length,
|
|
34 ngx_http_fastcgi_st_reserved,
|
|
35 ngx_http_fastcgi_st_data,
|
64
|
36 ngx_http_fastcgi_st_padding
|
50
|
37 } ngx_http_fastcgi_state_e;
|
|
38
|
|
39
|
|
40 typedef struct {
|
200
|
41 ngx_http_fastcgi_state_e state;
|
|
42 u_char *pos;
|
|
43 u_char *last;
|
|
44 ngx_uint_t type;
|
|
45 size_t length;
|
|
46 size_t padding;
|
|
47
|
|
48 ngx_uint_t fastcgi_stdout;
|
50
|
49 } ngx_http_fastcgi_ctx_t;
|
|
50
|
|
51
|
|
52 #define NGX_HTTP_FASTCGI_RESPONDER 1
|
|
53
|
|
54 #define NGX_HTTP_FASTCGI_BEGIN_REQUEST 1
|
|
55 #define NGX_HTTP_FASTCGI_ABORT_REQUEST 2
|
|
56 #define NGX_HTTP_FASTCGI_END_REQUEST 3
|
|
57 #define NGX_HTTP_FASTCGI_PARAMS 4
|
|
58 #define NGX_HTTP_FASTCGI_STDIN 5
|
|
59 #define NGX_HTTP_FASTCGI_STDOUT 6
|
|
60 #define NGX_HTTP_FASTCGI_STDERR 7
|
|
61 #define NGX_HTTP_FASTCGI_DATA 8
|
|
62
|
|
63
|
|
64 typedef struct {
|
|
65 u_char version;
|
|
66 u_char type;
|
|
67 u_char request_id_hi;
|
|
68 u_char request_id_lo;
|
|
69 u_char content_length_hi;
|
|
70 u_char content_length_lo;
|
|
71 u_char padding_length;
|
|
72 u_char reserved;
|
|
73 } ngx_http_fastcgi_header_t;
|
|
74
|
|
75
|
|
76 typedef struct {
|
|
77 u_char role_hi;
|
|
78 u_char role_lo;
|
|
79 u_char flags;
|
|
80 u_char reserved[5];
|
|
81 } ngx_http_fastcgi_begin_request_t;
|
|
82
|
|
83
|
58
|
84 typedef struct {
|
|
85 u_char version;
|
|
86 u_char type;
|
|
87 u_char request_id_hi;
|
|
88 u_char request_id_lo;
|
|
89 } ngx_http_fastcgi_header_small_t;
|
|
90
|
|
91
|
|
92 typedef struct {
|
|
93 ngx_http_fastcgi_header_t h0;
|
|
94 ngx_http_fastcgi_begin_request_t br;
|
|
95 ngx_http_fastcgi_header_small_t h1;
|
|
96 } ngx_http_fastcgi_request_start_t;
|
|
97
|
|
98
|
50
|
99 static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r);
|
|
100 static ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r);
|
|
101 static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r);
|
|
102 static ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p,
|
|
103 ngx_buf_t *buf);
|
|
104 static ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r,
|
|
105 ngx_http_fastcgi_ctx_t *f);
|
|
106 static void ngx_http_fastcgi_abort_request(ngx_http_request_t *r);
|
|
107 static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r,
|
|
108 ngx_int_t rc);
|
|
109
|
58
|
110 static ngx_int_t ngx_http_fastcgi_add_variables(ngx_conf_t *cf);
|
|
111 static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf);
|
|
112 static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf,
|
|
113 void *parent, void *child);
|
122
|
114 static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r,
|
|
115 ngx_http_variable_value_t *v, uintptr_t data);
|
58
|
116
|
50
|
117 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
118 void *conf);
|
|
119 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post,
|
|
120 void *data);
|
|
121
|
260
|
122 static char *ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf,
|
|
123 ngx_command_t *cmd, void *conf);
|
|
124 static char *ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf,
|
|
125 ngx_command_t *cmd, void *conf);
|
|
126
|
50
|
127
|
58
|
128 static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = {
|
|
129 { 1, /* version */
|
|
130 NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */
|
|
131 0, /* request_id_hi */
|
|
132 1, /* request_id_lo */
|
|
133 0, /* content_length_hi */
|
|
134 sizeof(ngx_http_fastcgi_begin_request_t), /* content_length_lo */
|
|
135 0, /* padding_length */
|
|
136 0 }, /* reserved */
|
|
137
|
|
138 { 0, /* role_hi */
|
|
139 NGX_HTTP_FASTCGI_RESPONDER, /* role_lo */
|
|
140 0, /* NGX_HTTP_FASTCGI_KEEP_CONN */ /* flags */
|
|
141 { 0, 0, 0, 0, 0 } }, /* reserved[5] */
|
|
142
|
|
143 { 1, /* version */
|
|
144 NGX_HTTP_FASTCGI_PARAMS, /* type */
|
|
145 0, /* request_id_hi */
|
|
146 1 }, /* request_id_lo */
|
|
147
|
|
148 };
|
|
149
|
|
150
|
|
151 static ngx_str_t ngx_http_fastcgi_script_name =
|
|
152 ngx_string("fastcgi_script_name");
|
50
|
153
|
|
154
|
58
|
155 static ngx_conf_post_t ngx_http_fastcgi_lowat_post =
|
|
156 { ngx_http_fastcgi_lowat_check };
|
50
|
157
|
130
|
158 static ngx_conf_deprecated_t ngx_conf_deprecated_fastcgi_header_buffer_size = {
|
|
159 ngx_conf_deprecated, "fastcgi_header_buffer_size", "fastcgi_buffer_size"
|
|
160 };
|
|
161
|
206
|
162 static ngx_conf_deprecated_t ngx_conf_deprecated_fastcgi_redirect_errors = {
|
|
163 ngx_conf_deprecated, "fastcgi_redirect_errors", "fastcgi_intercept_errors"
|
|
164 };
|
|
165
|
50
|
166
|
|
167 static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = {
|
|
168 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
|
|
169 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT },
|
|
170 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER },
|
|
171 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 },
|
172
|
172 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
|
50
|
173 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
|
214
|
174 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
|
50
|
175 { ngx_null_string, 0 }
|
|
176 };
|
|
177
|
|
178
|
|
179 static ngx_command_t ngx_http_fastcgi_commands[] = {
|
|
180
|
|
181 { ngx_string("fastcgi_pass"),
|
178
|
182 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
|
50
|
183 ngx_http_fastcgi_pass,
|
|
184 NGX_HTTP_LOC_CONF_OFFSET,
|
|
185 0,
|
|
186 NULL },
|
|
187
|
|
188 { ngx_string("fastcgi_index"),
|
|
189 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
190 ngx_conf_set_str_slot,
|
|
191 NGX_HTTP_LOC_CONF_OFFSET,
|
|
192 offsetof(ngx_http_fastcgi_loc_conf_t, index),
|
|
193 NULL },
|
|
194
|
178
|
195 { ngx_string("fastcgi_ignore_client_abort"),
|
|
196 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
197 ngx_conf_set_flag_slot,
|
|
198 NGX_HTTP_LOC_CONF_OFFSET,
|
|
199 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.ignore_client_abort),
|
|
200 NULL },
|
|
201
|
50
|
202 { ngx_string("fastcgi_connect_timeout"),
|
|
203 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
204 ngx_conf_set_msec_slot,
|
|
205 NGX_HTTP_LOC_CONF_OFFSET,
|
|
206 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.connect_timeout),
|
|
207 NULL },
|
|
208
|
|
209 { ngx_string("fastcgi_send_timeout"),
|
|
210 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
211 ngx_conf_set_msec_slot,
|
|
212 NGX_HTTP_LOC_CONF_OFFSET,
|
|
213 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_timeout),
|
|
214 NULL },
|
|
215
|
|
216 { ngx_string("fastcgi_send_lowat"),
|
|
217 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
218 ngx_conf_set_size_slot,
|
|
219 NGX_HTTP_LOC_CONF_OFFSET,
|
|
220 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_lowat),
|
|
221 &ngx_http_fastcgi_lowat_post },
|
|
222
|
130
|
223 { ngx_string("fastcgi_buffer_size"),
|
|
224 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
225 ngx_conf_set_size_slot,
|
|
226 NGX_HTTP_LOC_CONF_OFFSET,
|
|
227 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffer_size),
|
|
228 NULL },
|
|
229
|
50
|
230 { ngx_string("fastcgi_header_buffer_size"),
|
|
231 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
232 ngx_conf_set_size_slot,
|
|
233 NGX_HTTP_LOC_CONF_OFFSET,
|
130
|
234 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffer_size),
|
|
235 &ngx_conf_deprecated_fastcgi_header_buffer_size },
|
50
|
236
|
58
|
237 { ngx_string("fastcgi_pass_request_headers"),
|
|
238 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
239 ngx_conf_set_flag_slot,
|
|
240 NGX_HTTP_LOC_CONF_OFFSET,
|
|
241 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_headers),
|
|
242 NULL },
|
|
243
|
|
244 { ngx_string("fastcgi_pass_request_body"),
|
|
245 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
246 ngx_conf_set_flag_slot,
|
|
247 NGX_HTTP_LOC_CONF_OFFSET,
|
|
248 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_body),
|
|
249 NULL },
|
|
250
|
206
|
251 { ngx_string("fastcgi_intercept_errors"),
|
|
252 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
253 ngx_conf_set_flag_slot,
|
|
254 NGX_HTTP_LOC_CONF_OFFSET,
|
|
255 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.intercept_errors),
|
|
256 NULL },
|
|
257
|
50
|
258 { ngx_string("fastcgi_redirect_errors"),
|
|
259 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
260 ngx_conf_set_flag_slot,
|
|
261 NGX_HTTP_LOC_CONF_OFFSET,
|
206
|
262 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.intercept_errors),
|
|
263 &ngx_conf_deprecated_fastcgi_redirect_errors },
|
50
|
264
|
|
265 { ngx_string("fastcgi_read_timeout"),
|
|
266 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
267 ngx_conf_set_msec_slot,
|
|
268 NGX_HTTP_LOC_CONF_OFFSET,
|
|
269 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.read_timeout),
|
|
270 NULL },
|
|
271
|
|
272 { ngx_string("fastcgi_buffers"),
|
|
273 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
|
|
274 ngx_conf_set_bufs_slot,
|
|
275 NGX_HTTP_LOC_CONF_OFFSET,
|
|
276 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.bufs),
|
|
277 NULL },
|
|
278
|
|
279 { ngx_string("fastcgi_busy_buffers_size"),
|
|
280 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
281 ngx_conf_set_size_slot,
|
|
282 NGX_HTTP_LOC_CONF_OFFSET,
|
78
|
283 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf),
|
50
|
284 NULL },
|
|
285
|
|
286 { ngx_string("fastcgi_temp_path"),
|
|
287 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
|
|
288 ngx_conf_set_path_slot,
|
|
289 NGX_HTTP_LOC_CONF_OFFSET,
|
|
290 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_path),
|
|
291 (void *) ngx_garbage_collector_temp_handler },
|
|
292
|
|
293 { ngx_string("fastcgi_max_temp_file_size"),
|
|
294 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
295 ngx_conf_set_size_slot,
|
|
296 NGX_HTTP_LOC_CONF_OFFSET,
|
78
|
297 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size_conf),
|
50
|
298 NULL },
|
|
299
|
|
300 { ngx_string("fastcgi_temp_file_write_size"),
|
|
301 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
302 ngx_conf_set_size_slot,
|
|
303 NGX_HTTP_LOC_CONF_OFFSET,
|
78
|
304 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size_conf),
|
50
|
305 NULL },
|
|
306
|
|
307 { ngx_string("fastcgi_next_upstream"),
|
96
|
308 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
50
|
309 ngx_conf_set_bitmask_slot,
|
|
310 NGX_HTTP_LOC_CONF_OFFSET,
|
|
311 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream),
|
|
312 &ngx_http_fastcgi_next_upstream_masks },
|
|
313
|
110
|
314 { ngx_string("fastcgi_upstream_max_fails"),
|
|
315 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
260
|
316 ngx_http_fastcgi_upstream_max_fails_unsupported,
|
|
317 0,
|
|
318 0,
|
110
|
319 NULL },
|
|
320
|
|
321 { ngx_string("fastcgi_upstream_fail_timeout"),
|
|
322 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
260
|
323 ngx_http_fastcgi_upstream_fail_timeout_unsupported,
|
|
324 0,
|
|
325 0,
|
110
|
326 NULL },
|
|
327
|
58
|
328 { ngx_string("fastcgi_param"),
|
|
329 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
|
198
|
330 ngx_conf_set_keyval_slot,
|
50
|
331 NGX_HTTP_LOC_CONF_OFFSET,
|
58
|
332 offsetof(ngx_http_fastcgi_loc_conf_t, params_source),
|
50
|
333 NULL },
|
|
334
|
198
|
335 { ngx_string("fastcgi_pass_header"),
|
|
336 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
337 ngx_conf_set_str_array_slot,
|
|
338 NGX_HTTP_LOC_CONF_OFFSET,
|
|
339 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_headers),
|
|
340 NULL },
|
|
341
|
|
342 { ngx_string("fastcgi_hide_header"),
|
|
343 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
344 ngx_conf_set_str_array_slot,
|
|
345 NGX_HTTP_LOC_CONF_OFFSET,
|
|
346 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.hide_headers),
|
|
347 NULL },
|
|
348
|
306
|
349 { ngx_string("fastcgi_catch_stderr"),
|
|
350 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
351 ngx_conf_set_str_array_slot,
|
|
352 NGX_HTTP_LOC_CONF_OFFSET,
|
|
353 offsetof(ngx_http_fastcgi_loc_conf_t, catch_stderr),
|
|
354 NULL },
|
|
355
|
50
|
356 ngx_null_command
|
|
357 };
|
|
358
|
|
359
|
216
|
360 static ngx_http_module_t ngx_http_fastcgi_module_ctx = {
|
58
|
361 ngx_http_fastcgi_add_variables, /* preconfiguration */
|
|
362 NULL, /* postconfiguration */
|
50
|
363
|
|
364 NULL, /* create main configuration */
|
|
365 NULL, /* init main configuration */
|
|
366
|
|
367 NULL, /* create server configuration */
|
|
368 NULL, /* merge server configuration */
|
|
369
|
|
370 ngx_http_fastcgi_create_loc_conf, /* create location configuration */
|
|
371 ngx_http_fastcgi_merge_loc_conf /* merge location configuration */
|
|
372 };
|
|
373
|
|
374
|
|
375 ngx_module_t ngx_http_fastcgi_module = {
|
58
|
376 NGX_MODULE_V1,
|
50
|
377 &ngx_http_fastcgi_module_ctx, /* module context */
|
|
378 ngx_http_fastcgi_commands, /* module directives */
|
|
379 NGX_HTTP_MODULE, /* module type */
|
90
|
380 NULL, /* init master */
|
50
|
381 NULL, /* init module */
|
90
|
382 NULL, /* init process */
|
|
383 NULL, /* init thread */
|
|
384 NULL, /* exit thread */
|
|
385 NULL, /* exit process */
|
|
386 NULL, /* exit master */
|
|
387 NGX_MODULE_V1_PADDING
|
50
|
388 };
|
|
389
|
|
390
|
198
|
391 static ngx_str_t ngx_http_fastcgi_hide_headers[] = {
|
|
392 ngx_string("Status"),
|
|
393 ngx_string("X-Accel-Expires"),
|
|
394 ngx_string("X-Accel-Redirect"),
|
|
395 ngx_string("X-Accel-Limit-Rate"),
|
|
396 ngx_string("X-Accel-Buffer"),
|
|
397 ngx_null_string
|
|
398 };
|
|
399
|
|
400
|
50
|
401 static ngx_int_t
|
|
402 ngx_http_fastcgi_handler(ngx_http_request_t *r)
|
|
403 {
|
|
404 ngx_int_t rc;
|
|
405 ngx_http_upstream_t *u;
|
|
406 ngx_http_fastcgi_loc_conf_t *flcf;
|
|
407
|
248
|
408 if (r->subrequest_in_memory) {
|
|
409 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
|
410 "ngx_http_fastcgi_module does not support "
|
|
411 "subrequest in memeory");
|
|
412 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
413 }
|
|
414
|
50
|
415 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
|
|
416
|
|
417 u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));
|
|
418 if (u == NULL) {
|
|
419 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
420 }
|
|
421
|
|
422 u->peer.log = r->connection->log;
|
|
423 u->peer.log_error = NGX_ERROR_ERR;
|
|
424 #if (NGX_THREADS)
|
|
425 u->peer.lock = &r->connection->lock;
|
|
426 #endif
|
|
427
|
|
428 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module;
|
|
429
|
|
430 u->conf = &flcf->upstream;
|
|
431
|
|
432 u->create_request = ngx_http_fastcgi_create_request;
|
|
433 u->reinit_request = ngx_http_fastcgi_reinit_request;
|
|
434 u->process_header = ngx_http_fastcgi_process_header;
|
|
435 u->abort_request = ngx_http_fastcgi_abort_request;
|
|
436 u->finalize_request = ngx_http_fastcgi_finalize_request;
|
|
437
|
198
|
438 u->buffering = 1;
|
|
439
|
130
|
440 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
|
|
441 if (u->pipe == NULL) {
|
|
442 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
443 }
|
|
444
|
|
445 u->pipe->input_filter = ngx_http_fastcgi_input_filter;
|
|
446 u->pipe->input_ctx = r;
|
50
|
447
|
|
448 r->upstream = u;
|
|
449
|
|
450 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init);
|
|
451
|
|
452 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
453 return rc;
|
|
454 }
|
|
455
|
|
456 return NGX_DONE;
|
|
457 }
|
|
458
|
|
459
|
|
460 static ngx_int_t
|
|
461 ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|
462 {
|
58
|
463 off_t file_pos;
|
|
464 u_char ch, *pos;
|
|
465 size_t size, len, key_len, val_len, padding;
|
|
466 ngx_uint_t i, n, next;
|
|
467 ngx_buf_t *b;
|
|
468 ngx_chain_t *cl, *body;
|
|
469 ngx_list_part_t *part;
|
|
470 ngx_table_elt_t *header;
|
|
471 ngx_http_script_code_pt code;
|
|
472 ngx_http_script_engine_t e, le;
|
|
473 ngx_http_fastcgi_header_t *h;
|
|
474 ngx_http_fastcgi_loc_conf_t *flcf;
|
|
475 ngx_http_script_len_code_pt lcode;
|
50
|
476
|
58
|
477 len = 0;
|
50
|
478
|
|
479 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
|
|
480
|
58
|
481 if (flcf->params_len) {
|
|
482 ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
|
50
|
483
|
122
|
484 ngx_http_script_flush_no_cachable_variables(r, flcf->flushes);
|
|
485 le.flushed = 1;
|
|
486
|
58
|
487 le.ip = flcf->params_len->elts;
|
|
488 le.request = r;
|
50
|
489
|
58
|
490 while (*(uintptr_t *) le.ip) {
|
50
|
491
|
58
|
492 lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
|
493 key_len = lcode(&le);
|
50
|
494
|
58
|
495 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
|
|
496 lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
|
497 }
|
|
498 le.ip += sizeof(uintptr_t);
|
50
|
499
|
86
|
500 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len;
|
50
|
501 }
|
|
502 }
|
|
503
|
58
|
504 if (flcf->upstream.pass_request_headers) {
|
50
|
505
|
58
|
506 part = &r->headers_in.headers.part;
|
|
507 header = part->elts;
|
|
508
|
|
509 for (i = 0; /* void */; i++) {
|
50
|
510
|
58
|
511 if (i >= part->nelts) {
|
|
512 if (part->next == NULL) {
|
|
513 break;
|
|
514 }
|
50
|
515
|
58
|
516 part = part->next;
|
|
517 header = part->elts;
|
|
518 i = 0;
|
50
|
519 }
|
|
520
|
58
|
521 len += ((sizeof("HTTP_") - 1 + header[i].key.len > 127) ? 4 : 1)
|
|
522 + ((header[i].value.len > 127) ? 4 : 1)
|
|
523 + sizeof("HTTP_") - 1 + header[i].key.len + header[i].value.len;
|
50
|
524 }
|
|
525 }
|
|
526
|
|
527
|
|
528 if (len > 65535) {
|
|
529 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
|
530 "fastcgi: the request record is too big");
|
|
531 return NGX_ERROR;
|
|
532 }
|
|
533
|
|
534
|
|
535 padding = 8 - len % 8;
|
|
536 padding = (padding == 8) ? 0 : padding;
|
|
537
|
|
538
|
|
539 size = sizeof(ngx_http_fastcgi_header_t)
|
|
540 + sizeof(ngx_http_fastcgi_begin_request_t)
|
|
541
|
|
542 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */
|
|
543 + len + padding
|
|
544 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */
|
|
545
|
|
546 + sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */
|
|
547
|
|
548
|
|
549 b = ngx_create_temp_buf(r->pool, size);
|
|
550 if (b == NULL) {
|
|
551 return NGX_ERROR;
|
|
552 }
|
|
553
|
|
554 cl = ngx_alloc_chain_link(r->pool);
|
|
555 if (cl == NULL) {
|
|
556 return NGX_ERROR;
|
|
557 }
|
|
558
|
|
559 cl->buf = b;
|
|
560
|
58
|
561 ngx_memcpy(b->pos, &ngx_http_fastcgi_request_start,
|
|
562 sizeof(ngx_http_fastcgi_request_start_t));
|
50
|
563
|
|
564 h = (ngx_http_fastcgi_header_t *)
|
|
565 (b->pos + sizeof(ngx_http_fastcgi_header_t)
|
|
566 + sizeof(ngx_http_fastcgi_begin_request_t));
|
|
567
|
|
568 h->content_length_hi = (u_char) ((len >> 8) & 0xff);
|
|
569 h->content_length_lo = (u_char) (len & 0xff);
|
|
570 h->padding_length = (u_char) padding;
|
|
571 h->reserved = 0;
|
|
572
|
|
573 b->last = b->pos + sizeof(ngx_http_fastcgi_header_t)
|
|
574 + sizeof(ngx_http_fastcgi_begin_request_t)
|
|
575 + sizeof(ngx_http_fastcgi_header_t);
|
|
576
|
|
577
|
58
|
578 if (flcf->params_len) {
|
|
579 ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
50
|
580
|
58
|
581 e.ip = flcf->params->elts;
|
|
582 e.pos = b->last;
|
|
583 e.request = r;
|
122
|
584 e.flushed = 1;
|
50
|
585
|
58
|
586 le.ip = flcf->params_len->elts;
|
50
|
587
|
58
|
588 while (*(uintptr_t *) le.ip) {
|
50
|
589
|
58
|
590 lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
|
591 key_len = (u_char) lcode(&le);
|
50
|
592
|
58
|
593 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
|
|
594 lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
|
595 }
|
|
596 le.ip += sizeof(uintptr_t);
|
50
|
597
|
86
|
598 *e.pos++ = (u_char) key_len;
|
50
|
599
|
86
|
600 if (val_len > 127) {
|
|
601 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80);
|
|
602 *e.pos++ = (u_char) ((val_len >> 16) & 0xff);
|
|
603 *e.pos++ = (u_char) ((val_len >> 8) & 0xff);
|
|
604 *e.pos++ = (u_char) (val_len & 0xff);
|
50
|
605
|
86
|
606 } else {
|
|
607 *e.pos++ = (u_char) val_len;
|
58
|
608 }
|
50
|
609
|
58
|
610 while (*(uintptr_t *) e.ip) {
|
|
611 code = *(ngx_http_script_code_pt *) e.ip;
|
|
612 code((ngx_http_script_engine_t *) &e);
|
|
613 }
|
|
614 e.ip += sizeof(uintptr_t);
|
50
|
615 }
|
|
616
|
58
|
617 b->last = e.pos;
|
50
|
618 }
|
|
619
|
|
620
|
58
|
621 if (flcf->upstream.pass_request_headers) {
|
50
|
622
|
58
|
623 part = &r->headers_in.headers.part;
|
|
624 header = part->elts;
|
50
|
625
|
58
|
626 for (i = 0; /* void */; i++) {
|
50
|
627
|
58
|
628 if (i >= part->nelts) {
|
|
629 if (part->next == NULL) {
|
126
|
630 break;
|
58
|
631 }
|
126
|
632
|
58
|
633 part = part->next;
|
|
634 header = part->elts;
|
|
635 i = 0;
|
|
636 }
|
50
|
637
|
58
|
638 len = sizeof("HTTP_") - 1 + header[i].key.len;
|
|
639 if (len > 127) {
|
|
640 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80);
|
|
641 *b->last++ = (u_char) ((len >> 16) & 0xff);
|
|
642 *b->last++ = (u_char) ((len >> 8) & 0xff);
|
|
643 *b->last++ = (u_char) (len & 0xff);
|
126
|
644
|
58
|
645 } else {
|
|
646 *b->last++ = (u_char) len;
|
50
|
647 }
|
|
648
|
58
|
649 len = header[i].value.len;
|
|
650 if (len > 127) {
|
|
651 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80);
|
|
652 *b->last++ = (u_char) ((len >> 16) & 0xff);
|
|
653 *b->last++ = (u_char) ((len >> 8) & 0xff);
|
|
654 *b->last++ = (u_char) (len & 0xff);
|
50
|
655
|
58
|
656 } else {
|
|
657 *b->last++ = (u_char) len;
|
50
|
658 }
|
|
659
|
58
|
660 b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1);
|
50
|
661
|
58
|
662 for (n = 0; n < header[i].key.len; n++) {
|
|
663 ch = header[i].key.data[n];
|
50
|
664
|
58
|
665 if (ch >= 'a' && ch <= 'z') {
|
|
666 ch &= ~0x20;
|
50
|
667
|
58
|
668 } else if (ch == '-') {
|
|
669 ch = '_';
|
|
670 }
|
50
|
671
|
58
|
672 *b->last++ = ch;
|
50
|
673 }
|
|
674
|
122
|
675 b->last = ngx_copy(b->last, header[i].value.data,
|
|
676 header[i].value.len);
|
50
|
677 }
|
|
678 }
|
|
679
|
|
680
|
|
681 if (padding) {
|
|
682 ngx_memzero(b->last, padding);
|
|
683 b->last += padding;
|
|
684 }
|
|
685
|
|
686
|
|
687 h = (ngx_http_fastcgi_header_t *) b->last;
|
|
688 b->last += sizeof(ngx_http_fastcgi_header_t);
|
|
689
|
|
690 h->version = 1;
|
|
691 h->type = NGX_HTTP_FASTCGI_PARAMS;
|
|
692 h->request_id_hi = 0;
|
|
693 h->request_id_lo = 1;
|
|
694 h->content_length_hi = 0;
|
|
695 h->content_length_lo = 0;
|
|
696 h->padding_length = 0;
|
|
697 h->reserved = 0;
|
|
698
|
|
699 h = (ngx_http_fastcgi_header_t *) b->last;
|
|
700 b->last += sizeof(ngx_http_fastcgi_header_t);
|
|
701
|
58
|
702 if (flcf->upstream.pass_request_body) {
|
|
703 body = r->upstream->request_bufs;
|
|
704 r->upstream->request_bufs = cl;
|
50
|
705
|
|
706 #if (NGX_SUPPRESS_WARN)
|
58
|
707 file_pos = 0;
|
|
708 pos = NULL;
|
50
|
709 #endif
|
|
710
|
58
|
711 while (body) {
|
50
|
712
|
58
|
713 if (body->buf->in_file) {
|
|
714 file_pos = body->buf->file_pos;
|
50
|
715
|
58
|
716 } else {
|
|
717 pos = body->buf->pos;
|
50
|
718 }
|
|
719
|
58
|
720 next = 0;
|
50
|
721
|
58
|
722 do {
|
|
723 b = ngx_alloc_buf(r->pool);
|
|
724 if (b == NULL) {
|
|
725 return NGX_ERROR;
|
50
|
726 }
|
|
727
|
58
|
728 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t));
|
|
729
|
|
730 if (body->buf->in_file) {
|
|
731 b->file_pos = file_pos;
|
|
732 file_pos += 32 * 1024;
|
50
|
733
|
292
|
734 if (file_pos >= body->buf->file_last) {
|
58
|
735 file_pos = body->buf->file_last;
|
|
736 next = 1;
|
|
737 }
|
|
738
|
|
739 b->file_last = file_pos;
|
|
740 len = (ngx_uint_t) (file_pos - b->file_pos);
|
|
741
|
|
742 } else {
|
|
743 b->pos = pos;
|
|
744 pos += 32 * 1024;
|
50
|
745
|
292
|
746 if (pos >= body->buf->last) {
|
58
|
747 pos = body->buf->last;
|
|
748 next = 1;
|
|
749 }
|
|
750
|
|
751 b->last = pos;
|
|
752 len = (ngx_uint_t) (pos - b->pos);
|
|
753 }
|
50
|
754
|
58
|
755 padding = 8 - len % 8;
|
|
756 padding = (padding == 8) ? 0 : padding;
|
50
|
757
|
58
|
758 h->version = 1;
|
|
759 h->type = NGX_HTTP_FASTCGI_STDIN;
|
|
760 h->request_id_hi = 0;
|
|
761 h->request_id_lo = 1;
|
|
762 h->content_length_hi = (u_char) ((len >> 8) & 0xff);
|
|
763 h->content_length_lo = (u_char) (len & 0xff);
|
|
764 h->padding_length = (u_char) padding;
|
|
765 h->reserved = 0;
|
50
|
766
|
58
|
767 cl->next = ngx_alloc_chain_link(r->pool);
|
|
768 if (cl->next == NULL) {
|
|
769 return NGX_ERROR;
|
|
770 }
|
50
|
771
|
58
|
772 cl = cl->next;
|
|
773 cl->buf = b;
|
|
774
|
|
775 b = ngx_create_temp_buf(r->pool,
|
|
776 sizeof(ngx_http_fastcgi_header_t)
|
|
777 + padding);
|
|
778 if (b == NULL) {
|
|
779 return NGX_ERROR;
|
|
780 }
|
50
|
781
|
58
|
782 if (padding) {
|
|
783 ngx_memzero(b->last, padding);
|
|
784 b->last += padding;
|
|
785 }
|
|
786
|
|
787 h = (ngx_http_fastcgi_header_t *) b->last;
|
|
788 b->last += sizeof(ngx_http_fastcgi_header_t);
|
50
|
789
|
58
|
790 cl->next = ngx_alloc_chain_link(r->pool);
|
|
791 if (cl->next == NULL) {
|
|
792 return NGX_ERROR;
|
|
793 }
|
|
794
|
|
795 cl = cl->next;
|
|
796 cl->buf = b;
|
50
|
797
|
58
|
798 } while (!next);
|
50
|
799
|
58
|
800 body = body->next;
|
|
801 }
|
50
|
802
|
58
|
803 } else {
|
|
804 r->upstream->request_bufs = cl;
|
50
|
805 }
|
|
806
|
|
807 h->version = 1;
|
|
808 h->type = NGX_HTTP_FASTCGI_STDIN;
|
|
809 h->request_id_hi = 0;
|
|
810 h->request_id_lo = 1;
|
|
811 h->content_length_hi = 0;
|
|
812 h->content_length_lo = 0;
|
|
813 h->padding_length = 0;
|
|
814 h->reserved = 0;
|
|
815
|
|
816 cl->next = NULL;
|
|
817
|
|
818 return NGX_OK;
|
|
819 }
|
|
820
|
|
821
|
|
822 static ngx_int_t
|
|
823 ngx_http_fastcgi_reinit_request(ngx_http_request_t *r)
|
|
824 {
|
|
825 ngx_http_fastcgi_ctx_t *f;
|
|
826
|
|
827 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
|
|
828
|
|
829 if (f == NULL) {
|
|
830 return NGX_OK;
|
|
831 }
|
|
832
|
|
833 f->state = ngx_http_fastcgi_st_version;
|
164
|
834 f->fastcgi_stdout = 0;
|
50
|
835
|
|
836 return NGX_OK;
|
|
837 }
|
|
838
|
|
839
|
56
|
840 static ngx_int_t
|
|
841 ngx_http_fastcgi_process_header(ngx_http_request_t *r)
|
50
|
842 {
|
58
|
843 u_char *start, *last;
|
306
|
844 ngx_str_t *status_line, line, *pattern;
|
58
|
845 ngx_int_t rc, status;
|
198
|
846 ngx_uint_t i;
|
58
|
847 ngx_table_elt_t *h;
|
|
848 ngx_http_upstream_t *u;
|
|
849 ngx_http_fastcgi_ctx_t *f;
|
|
850 ngx_http_upstream_header_t *hh;
|
306
|
851 ngx_http_fastcgi_loc_conf_t *flcf;
|
58
|
852 ngx_http_upstream_main_conf_t *umcf;
|
50
|
853
|
|
854 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
|
|
855
|
58
|
856 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
|
857
|
50
|
858 if (f == NULL) {
|
|
859 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t));
|
|
860 if (f == NULL) {
|
|
861 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
862 }
|
|
863
|
|
864 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module);
|
|
865 }
|
|
866
|
|
867 u = r->upstream;
|
|
868
|
|
869 for ( ;; ) {
|
|
870
|
|
871 if (f->state < ngx_http_fastcgi_st_data) {
|
|
872
|
130
|
873 f->pos = u->buffer.pos;
|
|
874 f->last = u->buffer.last;
|
50
|
875
|
|
876 rc = ngx_http_fastcgi_process_record(r, f);
|
|
877
|
130
|
878 u->buffer.pos = f->pos;
|
|
879 u->buffer.last = f->last;
|
50
|
880
|
|
881 if (rc == NGX_AGAIN) {
|
|
882 return NGX_AGAIN;
|
|
883 }
|
|
884
|
|
885 if (rc == NGX_ERROR) {
|
|
886 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
|
|
887 }
|
|
888
|
|
889 if (f->type != NGX_HTTP_FASTCGI_STDOUT
|
|
890 && f->type != NGX_HTTP_FASTCGI_STDERR)
|
|
891 {
|
|
892 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
893 "upstream sent unexpected FastCGI record: %d",
|
|
894 f->type);
|
|
895
|
|
896 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
|
|
897 }
|
|
898
|
|
899 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) {
|
|
900 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
901 "upstream closed prematurely FastCGI stdout");
|
|
902
|
|
903 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
|
|
904 }
|
|
905 }
|
|
906
|
|
907 if (f->state == ngx_http_fastcgi_st_padding) {
|
|
908
|
130
|
909 if (u->buffer.pos + f->padding < u->buffer.last) {
|
50
|
910 f->state = ngx_http_fastcgi_st_version;
|
130
|
911 u->buffer.pos += f->padding;
|
50
|
912
|
|
913 continue;
|
|
914 }
|
|
915
|
130
|
916 if (u->buffer.pos + f->padding == u->buffer.last) {
|
50
|
917 f->state = ngx_http_fastcgi_st_version;
|
130
|
918 u->buffer.pos = u->buffer.last;
|
50
|
919
|
|
920 return NGX_AGAIN;
|
|
921 }
|
|
922
|
130
|
923 f->padding -= u->buffer.last - u->buffer.pos;
|
|
924 u->buffer.pos = u->buffer.last;
|
50
|
925
|
|
926 return NGX_AGAIN;
|
|
927 }
|
|
928
|
|
929
|
|
930 /* f->state == ngx_http_fastcgi_st_data */
|
|
931
|
|
932 if (f->type == NGX_HTTP_FASTCGI_STDERR) {
|
|
933
|
|
934 if (f->length) {
|
130
|
935 line.data = u->buffer.pos;
|
50
|
936
|
130
|
937 if (u->buffer.pos + f->length <= u->buffer.last) {
|
50
|
938 line.len = f->length;
|
130
|
939 u->buffer.pos += f->length;
|
50
|
940 f->length = 0;
|
|
941 f->state = ngx_http_fastcgi_st_padding;
|
|
942
|
126
|
943 } else {
|
130
|
944 line.len = u->buffer.last - u->buffer.pos;
|
|
945 f->length -= u->buffer.last - u->buffer.pos;
|
|
946 u->buffer.pos = u->buffer.last;
|
50
|
947 }
|
|
948
|
|
949 while (line.data[line.len - 1] == LF
|
|
950 || line.data[line.len - 1] == CR
|
|
951 || line.data[line.len - 1] == '.'
|
|
952 || line.data[line.len - 1] == ' ')
|
|
953 {
|
|
954 line.len--;
|
|
955 }
|
|
956
|
|
957 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
958 "FastCGI sent in stderr: \"%V\"", &line);
|
|
959
|
306
|
960 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
|
|
961
|
|
962 if (flcf->catch_stderr) {
|
|
963 pattern = flcf->catch_stderr->elts;
|
|
964
|
|
965 line.data[line.len - 1] = '\0';
|
|
966
|
|
967 for (i = 0; i < flcf->catch_stderr->nelts; i++) {
|
|
968 if (ngx_strstr(line.data, pattern[i].data)) {
|
|
969 return NGX_HTTP_BAD_GATEWAY;
|
|
970 }
|
|
971 }
|
|
972 }
|
|
973
|
130
|
974 if (u->buffer.pos == u->buffer.last) {
|
164
|
975
|
|
976 if (!f->fastcgi_stdout) {
|
|
977
|
|
978 /*
|
|
979 * the special handling the large number
|
|
980 * of the PHP warnings to not allocate memory
|
|
981 */
|
|
982
|
|
983 u->buffer.pos = u->buffer.start;
|
|
984 u->buffer.last = u->buffer.start;
|
|
985 }
|
|
986
|
50
|
987 return NGX_AGAIN;
|
|
988 }
|
|
989
|
|
990 } else {
|
|
991 f->state = ngx_http_fastcgi_st_version;
|
|
992 }
|
|
993
|
|
994 continue;
|
|
995 }
|
|
996
|
|
997
|
|
998 /* f->type == NGX_HTTP_FASTCGI_STDOUT */
|
|
999
|
164
|
1000 f->fastcgi_stdout = 1;
|
|
1001
|
130
|
1002 start = u->buffer.pos;
|
50
|
1003
|
130
|
1004 if (u->buffer.pos + f->length < u->buffer.last) {
|
50
|
1005
|
|
1006 /*
|
130
|
1007 * set u->buffer.last to the end of the FastCGI record data
|
50
|
1008 * for ngx_http_parse_header_line()
|
|
1009 */
|
|
1010
|
130
|
1011 last = u->buffer.last;
|
|
1012 u->buffer.last = u->buffer.pos + f->length;
|
50
|
1013
|
|
1014 } else {
|
|
1015 last = NULL;
|
|
1016 }
|
|
1017
|
|
1018 for ( ;; ) {
|
|
1019
|
130
|
1020 rc = ngx_http_parse_header_line(r, &u->buffer);
|
50
|
1021
|
|
1022 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1023 "http fastcgi parser: %d", rc);
|
|
1024
|
|
1025 if (rc == NGX_AGAIN) {
|
|
1026 break;
|
|
1027 }
|
|
1028
|
|
1029 if (rc == NGX_OK) {
|
|
1030
|
|
1031 /* a header line has been parsed successfully */
|
|
1032
|
58
|
1033 h = ngx_list_push(&u->headers_in.headers);
|
50
|
1034 if (h == NULL) {
|
|
1035 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1036 }
|
|
1037
|
58
|
1038 h->hash = r->header_hash;
|
|
1039
|
50
|
1040 h->key.len = r->header_name_end - r->header_name_start;
|
|
1041 h->value.len = r->header_end - r->header_start;
|
|
1042
|
|
1043 h->key.data = ngx_palloc(r->pool,
|
198
|
1044 h->key.len + 1 + h->value.len + 1 + h->key.len);
|
50
|
1045 if (h->key.data == NULL) {
|
|
1046 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1047 }
|
|
1048
|
|
1049 h->value.data = h->key.data + h->key.len + 1;
|
198
|
1050 h->lowcase_key = h->key.data + h->key.len + 1
|
|
1051 + h->value.len + 1;
|
50
|
1052
|
|
1053 ngx_cpystrn(h->key.data, r->header_name_start, h->key.len + 1);
|
|
1054 ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1);
|
|
1055
|
198
|
1056 if (h->key.len == r->lowcase_index) {
|
|
1057 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);
|
|
1058
|
|
1059 } else {
|
|
1060 for (i = 0; i < h->key.len; i++) {
|
|
1061 h->lowcase_key[i] = ngx_tolower(h->lowcase_key[i]);
|
50
|
1062 }
|
|
1063 }
|
|
1064
|
198
|
1065 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
|
|
1066 h->lowcase_key, h->key.len);
|
|
1067
|
|
1068 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
|
|
1069 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1070 }
|
|
1071
|
50
|
1072 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1073 "http fastcgi header: \"%V: %V\"",
|
|
1074 &h->key, &h->value);
|
|
1075
|
164
|
1076 if (u->buffer.pos < u->buffer.last) {
|
|
1077 continue;
|
|
1078 }
|
|
1079
|
|
1080 /* the end of the FastCGI record */
|
|
1081
|
|
1082 break;
|
50
|
1083 }
|
|
1084
|
|
1085 if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
|
|
1086
|
|
1087 /* a whole header has been parsed successfully */
|
|
1088
|
|
1089 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1090 "http fastcgi header done");
|
|
1091
|
58
|
1092 if (u->headers_in.status) {
|
|
1093 status_line = &u->headers_in.status->value;
|
50
|
1094
|
|
1095 status = ngx_atoi(status_line->data, 3);
|
|
1096
|
|
1097 if (status == NGX_ERROR) {
|
|
1098 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1099 }
|
|
1100
|
78
|
1101 u->headers_in.status_n = status;
|
|
1102 u->headers_in.status_line = *status_line;
|
50
|
1103
|
|
1104 } else {
|
78
|
1105 u->headers_in.status_n = 200;
|
|
1106 u->headers_in.status_line.len = sizeof("200 OK") - 1;
|
|
1107 u->headers_in.status_line.data = (u_char *) "200 OK";
|
50
|
1108 }
|
|
1109
|
78
|
1110 u->state->status = u->headers_in.status_n;
|
50
|
1111 #if 0
|
|
1112 if (u->cachable) {
|
|
1113 u->cachable = ngx_http_upstream_is_cachable(r);
|
|
1114 }
|
|
1115 #endif
|
|
1116
|
|
1117 break;
|
|
1118 }
|
|
1119
|
|
1120 /* there was error while a header line parsing */
|
|
1121
|
|
1122 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
168
|
1123 "upstream sent invalid header");
|
50
|
1124
|
|
1125 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
|
|
1126
|
|
1127 }
|
|
1128
|
|
1129 if (last) {
|
130
|
1130 u->buffer.last = last;
|
50
|
1131 }
|
|
1132
|
130
|
1133 f->length -= u->buffer.pos - start;
|
50
|
1134
|
|
1135 if (f->length == 0) {
|
|
1136 if (f->padding) {
|
|
1137 f->state = ngx_http_fastcgi_st_padding;
|
|
1138 } else {
|
|
1139 f->state = ngx_http_fastcgi_st_version;
|
|
1140 }
|
|
1141 }
|
|
1142
|
164
|
1143 if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
|
|
1144 return NGX_OK;
|
|
1145 }
|
|
1146
|
|
1147 if (u->buffer.pos == u->buffer.last) {
|
|
1148 return NGX_AGAIN;
|
|
1149 }
|
|
1150
|
|
1151 if (rc == NGX_AGAIN) {
|
|
1152 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
|
1153 "upstream split a header line in FastCGI records");
|
|
1154
|
|
1155 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
|
|
1156 }
|
50
|
1157 }
|
|
1158 }
|
|
1159
|
|
1160
|
|
1161 static ngx_int_t
|
|
1162 ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|
1163 {
|
|
1164 ngx_int_t rc;
|
|
1165 ngx_buf_t *b, **prev;
|
|
1166 ngx_str_t line;
|
|
1167 ngx_chain_t *cl;
|
|
1168 ngx_http_request_t *r;
|
|
1169 ngx_http_fastcgi_ctx_t *f;
|
|
1170
|
|
1171 if (buf->pos == buf->last) {
|
|
1172 return NGX_OK;
|
|
1173 }
|
|
1174
|
|
1175 r = p->input_ctx;
|
|
1176 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
|
|
1177
|
|
1178 b = NULL;
|
|
1179 prev = &buf->shadow;
|
|
1180
|
|
1181 f->pos = buf->pos;
|
|
1182 f->last = buf->last;
|
|
1183
|
|
1184 for ( ;; ) {
|
|
1185 if (f->state < ngx_http_fastcgi_st_data) {
|
|
1186
|
|
1187 rc = ngx_http_fastcgi_process_record(r, f);
|
|
1188
|
|
1189 if (rc == NGX_AGAIN) {
|
|
1190 break;
|
|
1191 }
|
|
1192
|
|
1193 if (rc == NGX_ERROR) {
|
|
1194 return NGX_ERROR;
|
|
1195 }
|
|
1196
|
|
1197 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) {
|
|
1198 f->state = ngx_http_fastcgi_st_version;
|
|
1199 p->upstream_done = 1;
|
|
1200
|
|
1201 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0,
|
|
1202 "http fastcgi closed stdout");
|
|
1203
|
|
1204 continue;
|
|
1205 }
|
|
1206
|
|
1207 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) {
|
|
1208 f->state = ngx_http_fastcgi_st_version;
|
|
1209 p->upstream_done = 1;
|
|
1210
|
|
1211 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0,
|
|
1212 "http fastcgi sent end request");
|
|
1213
|
|
1214 break;
|
|
1215 }
|
|
1216 }
|
|
1217
|
|
1218
|
|
1219 if (f->state == ngx_http_fastcgi_st_padding) {
|
|
1220
|
|
1221 if (f->pos + f->padding < f->last) {
|
|
1222 f->state = ngx_http_fastcgi_st_version;
|
|
1223 f->pos += f->padding;
|
|
1224
|
|
1225 continue;
|
|
1226 }
|
|
1227
|
|
1228 if (f->pos + f->padding == f->last) {
|
|
1229 f->state = ngx_http_fastcgi_st_version;
|
|
1230
|
|
1231 break;
|
|
1232 }
|
|
1233
|
|
1234 f->padding -= f->last - f->pos;
|
|
1235
|
|
1236 break;
|
|
1237 }
|
|
1238
|
|
1239
|
|
1240 /* f->state == ngx_http_fastcgi_st_data */
|
|
1241
|
|
1242 if (f->type == NGX_HTTP_FASTCGI_STDERR) {
|
|
1243
|
|
1244 if (f->length) {
|
188
|
1245
|
|
1246 if (f->pos == f->last) {
|
|
1247 break;
|
|
1248 }
|
|
1249
|
50
|
1250 line.data = f->pos;
|
|
1251
|
|
1252 if (f->pos + f->length <= f->last) {
|
|
1253 line.len = f->length;
|
|
1254 f->pos += f->length;
|
|
1255 f->length = 0;
|
|
1256 f->state = ngx_http_fastcgi_st_padding;
|
|
1257
|
126
|
1258 } else {
|
50
|
1259 line.len = f->last - f->pos;
|
|
1260 f->length -= f->last - f->pos;
|
|
1261 f->pos = f->last;
|
|
1262 }
|
|
1263
|
|
1264 while (line.data[line.len - 1] == LF
|
|
1265 || line.data[line.len - 1] == CR
|
|
1266 || line.data[line.len - 1] == '.'
|
|
1267 || line.data[line.len - 1] == ' ')
|
|
1268 {
|
|
1269 line.len--;
|
|
1270 }
|
|
1271
|
|
1272 ngx_log_error(NGX_LOG_ERR, p->log, 0,
|
|
1273 "FastCGI sent in stderr: \"%V\"", &line);
|
|
1274
|
|
1275 if (f->pos == f->last) {
|
|
1276 break;
|
|
1277 }
|
|
1278
|
|
1279 } else {
|
|
1280 f->state = ngx_http_fastcgi_st_version;
|
|
1281 }
|
|
1282
|
|
1283 continue;
|
|
1284 }
|
|
1285
|
|
1286
|
|
1287 /* f->type == NGX_HTTP_FASTCGI_STDOUT */
|
|
1288
|
188
|
1289 if (f->pos == f->last) {
|
|
1290 break;
|
|
1291 }
|
|
1292
|
50
|
1293 if (p->free) {
|
|
1294 b = p->free->buf;
|
|
1295 p->free = p->free->next;
|
|
1296
|
|
1297 } else {
|
|
1298 b = ngx_alloc_buf(p->pool);
|
|
1299 if (b == NULL) {
|
|
1300 return NGX_ERROR;
|
|
1301 }
|
|
1302 }
|
|
1303
|
|
1304 ngx_memzero(b, sizeof(ngx_buf_t));
|
|
1305
|
|
1306 b->pos = f->pos;
|
|
1307 b->start = buf->start;
|
|
1308 b->end = buf->end;
|
|
1309 b->tag = p->tag;
|
|
1310 b->temporary = 1;
|
|
1311 b->recycled = 1;
|
|
1312
|
|
1313 *prev = b;
|
|
1314 prev = &b->shadow;
|
|
1315
|
|
1316 cl = ngx_alloc_chain_link(p->pool);
|
|
1317 if (cl == NULL) {
|
|
1318 return NGX_ERROR;
|
|
1319 }
|
|
1320
|
|
1321 cl->buf = b;
|
|
1322 cl->next = NULL;
|
|
1323
|
|
1324 if (p->in) {
|
|
1325 *p->last_in = cl;
|
|
1326 } else {
|
|
1327 p->in = cl;
|
|
1328 }
|
|
1329 p->last_in = &cl->next;
|
|
1330
|
|
1331
|
|
1332 /* STUB */ b->num = buf->num;
|
|
1333
|
274
|
1334 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
276
|
1335 "input buf #%d %p", b->num, b->pos);
|
50
|
1336
|
|
1337 if (f->pos + f->length < f->last) {
|
|
1338
|
|
1339 if (f->padding) {
|
|
1340 f->state = ngx_http_fastcgi_st_padding;
|
|
1341 } else {
|
|
1342 f->state = ngx_http_fastcgi_st_version;
|
|
1343 }
|
|
1344
|
|
1345 f->pos += f->length;
|
|
1346 b->last = f->pos;
|
|
1347
|
|
1348 continue;
|
|
1349 }
|
|
1350
|
|
1351 if (f->pos + f->length == f->last) {
|
|
1352
|
|
1353 if (f->padding) {
|
|
1354 f->state = ngx_http_fastcgi_st_padding;
|
|
1355 } else {
|
|
1356 f->state = ngx_http_fastcgi_st_version;
|
|
1357 }
|
|
1358
|
|
1359 b->last = f->last;
|
|
1360
|
|
1361 break;
|
|
1362 }
|
|
1363
|
|
1364 f->length -= f->last - f->pos;
|
|
1365
|
|
1366 b->last = f->last;
|
|
1367
|
|
1368 break;
|
|
1369
|
|
1370 }
|
|
1371
|
|
1372 if (b) {
|
|
1373 b->shadow = buf;
|
|
1374 b->last_shadow = 1;
|
|
1375
|
274
|
1376 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
276
|
1377 "input buf %p %z", b->pos, b->last - b->pos);
|
274
|
1378
|
50
|
1379 return NGX_OK;
|
|
1380 }
|
|
1381
|
|
1382 /* there is no data record in the buf, add it to free chain */
|
|
1383
|
|
1384 if (ngx_event_pipe_add_free_buf(p, buf) != NGX_OK) {
|
|
1385 return NGX_ERROR;
|
|
1386 }
|
|
1387
|
|
1388 return NGX_OK;
|
|
1389 }
|
|
1390
|
|
1391
|
|
1392 static ngx_int_t
|
|
1393 ngx_http_fastcgi_process_record(ngx_http_request_t *r,
|
|
1394 ngx_http_fastcgi_ctx_t *f)
|
|
1395 {
|
|
1396 u_char ch, *p;
|
|
1397 ngx_http_fastcgi_state_e state;
|
|
1398
|
|
1399 state = f->state;
|
|
1400
|
|
1401 for (p = f->pos; p < f->last; p++) {
|
|
1402
|
|
1403 ch = *p;
|
|
1404
|
|
1405 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1406 "http fastcgi record byte: %02Xd", ch);
|
|
1407
|
|
1408 switch (state) {
|
|
1409
|
|
1410 case ngx_http_fastcgi_st_version:
|
|
1411 if (ch != 1) {
|
|
1412 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
1413 "upstream sent unsupported FastCGI "
|
|
1414 "protocol version: %d", ch);
|
|
1415 return NGX_ERROR;
|
|
1416 }
|
|
1417 state = ngx_http_fastcgi_st_type;
|
|
1418 break;
|
|
1419
|
|
1420 case ngx_http_fastcgi_st_type:
|
|
1421 switch (ch) {
|
|
1422 case NGX_HTTP_FASTCGI_STDOUT:
|
|
1423 case NGX_HTTP_FASTCGI_STDERR:
|
|
1424 case NGX_HTTP_FASTCGI_END_REQUEST:
|
|
1425 f->type = (ngx_uint_t) ch;
|
|
1426 break;
|
|
1427 default:
|
|
1428 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
1429 "upstream sent invalid FastCGI "
|
|
1430 "record type: %d", ch);
|
|
1431 return NGX_ERROR;
|
|
1432
|
|
1433 }
|
|
1434 state = ngx_http_fastcgi_st_request_id_hi;
|
|
1435 break;
|
|
1436
|
|
1437 /* we support the single request per connection */
|
|
1438
|
|
1439 case ngx_http_fastcgi_st_request_id_hi:
|
|
1440 if (ch != 0) {
|
|
1441 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
1442 "upstream sent unexpected FastCGI "
|
|
1443 "request id high byte: %d", ch);
|
|
1444 return NGX_ERROR;
|
|
1445 }
|
|
1446 state = ngx_http_fastcgi_st_request_id_lo;
|
|
1447 break;
|
|
1448
|
|
1449 case ngx_http_fastcgi_st_request_id_lo:
|
|
1450 if (ch != 1) {
|
|
1451 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
1452 "upstream sent unexpected FastCGI "
|
|
1453 "request id low byte: %d", ch);
|
|
1454 return NGX_ERROR;
|
|
1455 }
|
|
1456 state = ngx_http_fastcgi_st_content_length_hi;
|
|
1457 break;
|
|
1458
|
|
1459 case ngx_http_fastcgi_st_content_length_hi:
|
|
1460 f->length = ch << 8;
|
|
1461 state = ngx_http_fastcgi_st_content_length_lo;
|
|
1462 break;
|
|
1463
|
|
1464 case ngx_http_fastcgi_st_content_length_lo:
|
|
1465 f->length |= (size_t) ch;
|
|
1466 state = ngx_http_fastcgi_st_padding_length;
|
|
1467 break;
|
|
1468
|
|
1469 case ngx_http_fastcgi_st_padding_length:
|
|
1470 f->padding = (size_t) ch;
|
|
1471 state = ngx_http_fastcgi_st_reserved;
|
|
1472 break;
|
|
1473
|
|
1474 case ngx_http_fastcgi_st_reserved:
|
|
1475 state = ngx_http_fastcgi_st_data;
|
|
1476
|
|
1477 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1478 "http fastcgi record length: %z", f->length);
|
|
1479
|
|
1480 f->pos = p + 1;
|
|
1481 f->state = state;
|
|
1482
|
|
1483 return NGX_OK;
|
|
1484
|
|
1485 /* suppress warning */
|
|
1486 case ngx_http_fastcgi_st_data:
|
|
1487 case ngx_http_fastcgi_st_padding:
|
|
1488 break;
|
|
1489 }
|
|
1490 }
|
|
1491
|
|
1492 f->state = state;
|
|
1493
|
|
1494 return NGX_AGAIN;
|
|
1495 }
|
|
1496
|
|
1497
|
|
1498 static void
|
|
1499 ngx_http_fastcgi_abort_request(ngx_http_request_t *r)
|
|
1500 {
|
|
1501 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1502 "abort http fastcgi request");
|
|
1503
|
|
1504 return;
|
|
1505 }
|
|
1506
|
|
1507
|
|
1508 static void
|
|
1509 ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
|
1510 {
|
|
1511 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1512 "finalize http fastcgi request");
|
|
1513
|
|
1514 return;
|
|
1515 }
|
|
1516
|
|
1517
|
58
|
1518 static ngx_int_t
|
|
1519 ngx_http_fastcgi_add_variables(ngx_conf_t *cf)
|
50
|
1520 {
|
58
|
1521 ngx_http_variable_t *var;
|
50
|
1522
|
132
|
1523 var = ngx_http_add_variable(cf, &ngx_http_fastcgi_script_name,
|
204
|
1524 NGX_HTTP_VAR_NOHASH|NGX_HTTP_VAR_NOCACHABLE);
|
58
|
1525 if (var == NULL) {
|
|
1526 return NGX_ERROR;
|
50
|
1527 }
|
|
1528
|
186
|
1529 var->get_handler = ngx_http_fastcgi_script_name_variable;
|
50
|
1530
|
58
|
1531 return NGX_OK;
|
50
|
1532 }
|
|
1533
|
|
1534
|
|
1535 static void *
|
|
1536 ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf)
|
|
1537 {
|
|
1538 ngx_http_fastcgi_loc_conf_t *conf;
|
|
1539
|
|
1540 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t));
|
|
1541 if (conf == NULL) {
|
|
1542 return NGX_CONF_ERROR;
|
|
1543 }
|
|
1544
|
|
1545 /*
|
|
1546 * set by ngx_pcalloc():
|
|
1547 *
|
|
1548 * conf->upstream.bufs.num = 0;
|
|
1549 * conf->upstream.next_upstream = 0;
|
|
1550 * conf->upstream.temp_path = NULL;
|
198
|
1551 * conf->upstream.hide_headers_hash = { NULL, 0 };
|
|
1552 * conf->upstream.hide_headers = NULL;
|
|
1553 * conf->upstream.pass_headers = NULL;
|
306
|
1554 * conf->upstream.catch_stderr = NULL;
|
58
|
1555 * conf->upstream.schema = { 0, NULL };
|
|
1556 * conf->upstream.uri = { 0, NULL };
|
|
1557 * conf->upstream.location = NULL;
|
|
1558 *
|
50
|
1559 * conf->index.len = 0;
|
|
1560 * conf->index.data = NULL;
|
|
1561 */
|
|
1562
|
130
|
1563 conf->upstream.buffering = NGX_CONF_UNSET;
|
178
|
1564 conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
|
130
|
1565
|
50
|
1566 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
|
|
1567 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
|
56
|
1568 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
|
|
1569
|
50
|
1570 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
|
130
|
1571 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;
|
78
|
1572
|
|
1573 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
|
126
|
1574 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
|
78
|
1575 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
|
58
|
1576
|
|
1577 conf->upstream.pass_request_headers = NGX_CONF_UNSET;
|
|
1578 conf->upstream.pass_request_body = NGX_CONF_UNSET;
|
|
1579
|
206
|
1580 conf->upstream.intercept_errors = NGX_CONF_UNSET;
|
50
|
1581
|
|
1582 /* "fastcgi_cyclic_temp_file" is disabled */
|
|
1583 conf->upstream.cyclic_temp_file = 0;
|
|
1584
|
|
1585 return conf;
|
|
1586 }
|
|
1587
|
|
1588
|
|
1589 static char *
|
|
1590 ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|
1591 {
|
|
1592 ngx_http_fastcgi_loc_conf_t *prev = parent;
|
|
1593 ngx_http_fastcgi_loc_conf_t *conf = child;
|
|
1594
|
58
|
1595 u_char *p;
|
|
1596 size_t size;
|
|
1597 uintptr_t *code;
|
198
|
1598 ngx_str_t *header;
|
|
1599 ngx_uint_t i, j;
|
|
1600 ngx_array_t hide_headers;
|
|
1601 ngx_keyval_t *src;
|
|
1602 ngx_hash_key_t *hk;
|
|
1603 ngx_hash_init_t hash;
|
58
|
1604 ngx_http_script_compile_t sc;
|
|
1605 ngx_http_script_copy_code_t *copy;
|
50
|
1606
|
130
|
1607 ngx_conf_merge_value(conf->upstream.buffering,
|
|
1608 prev->upstream.buffering, 1);
|
|
1609
|
178
|
1610 ngx_conf_merge_value(conf->upstream.ignore_client_abort,
|
|
1611 prev->upstream.ignore_client_abort, 0);
|
|
1612
|
50
|
1613 ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
|
|
1614 prev->upstream.connect_timeout, 60000);
|
56
|
1615
|
50
|
1616 ngx_conf_merge_msec_value(conf->upstream.send_timeout,
|
|
1617 prev->upstream.send_timeout, 60000);
|
|
1618
|
|
1619 ngx_conf_merge_msec_value(conf->upstream.read_timeout,
|
|
1620 prev->upstream.read_timeout, 60000);
|
|
1621
|
56
|
1622 ngx_conf_merge_size_value(conf->upstream.send_lowat,
|
|
1623 prev->upstream.send_lowat, 0);
|
50
|
1624
|
130
|
1625 ngx_conf_merge_size_value(conf->upstream.buffer_size,
|
|
1626 prev->upstream.buffer_size,
|
50
|
1627 (size_t) ngx_pagesize);
|
|
1628
|
56
|
1629
|
50
|
1630 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
|
|
1631 8, ngx_pagesize);
|
|
1632
|
|
1633 if (conf->upstream.bufs.num < 2) {
|
|
1634 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1635 "there must be at least 2 \"fastcgi_buffers\"");
|
|
1636 return NGX_CONF_ERROR;
|
|
1637 }
|
|
1638
|
|
1639
|
130
|
1640 size = conf->upstream.buffer_size;
|
50
|
1641 if (size < conf->upstream.bufs.size) {
|
|
1642 size = conf->upstream.bufs.size;
|
|
1643 }
|
|
1644
|
|
1645
|
78
|
1646 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
|
|
1647 prev->upstream.busy_buffers_size_conf,
|
50
|
1648 NGX_CONF_UNSET_SIZE);
|
|
1649
|
78
|
1650 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
|
50
|
1651 conf->upstream.busy_buffers_size = 2 * size;
|
78
|
1652 } else {
|
|
1653 conf->upstream.busy_buffers_size =
|
|
1654 conf->upstream.busy_buffers_size_conf;
|
|
1655 }
|
50
|
1656
|
78
|
1657 if (conf->upstream.busy_buffers_size < size) {
|
50
|
1658 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1659 "\"fastcgi_busy_buffers_size\" must be equal or bigger than "
|
288
|
1660 "maximum of the value of \"fastcgi_buffer_size\" and "
|
50
|
1661 "one of the \"fastcgi_buffers\"");
|
|
1662
|
|
1663 return NGX_CONF_ERROR;
|
78
|
1664 }
|
50
|
1665
|
78
|
1666 if (conf->upstream.busy_buffers_size
|
|
1667 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
|
50
|
1668 {
|
|
1669 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1670 "\"fastcgi_busy_buffers_size\" must be less than "
|
|
1671 "the size of all \"fastcgi_buffers\" minus one buffer");
|
|
1672
|
|
1673 return NGX_CONF_ERROR;
|
|
1674 }
|
|
1675
|
|
1676
|
78
|
1677 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
|
|
1678 prev->upstream.temp_file_write_size_conf,
|
50
|
1679 NGX_CONF_UNSET_SIZE);
|
|
1680
|
78
|
1681 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
|
50
|
1682 conf->upstream.temp_file_write_size = 2 * size;
|
78
|
1683 } else {
|
|
1684 conf->upstream.temp_file_write_size =
|
|
1685 conf->upstream.temp_file_write_size_conf;
|
|
1686 }
|
50
|
1687
|
78
|
1688 if (conf->upstream.temp_file_write_size < size) {
|
50
|
1689 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1690 "\"fastcgi_temp_file_write_size\" must be equal or bigger than "
|
288
|
1691 "maximum of the value of \"fastcgi_buffer_size\" and "
|
50
|
1692 "one of the \"fastcgi_buffers\"");
|
|
1693
|
|
1694 return NGX_CONF_ERROR;
|
|
1695 }
|
|
1696
|
|
1697
|
78
|
1698 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
|
|
1699 prev->upstream.max_temp_file_size_conf,
|
50
|
1700 NGX_CONF_UNSET_SIZE);
|
|
1701
|
78
|
1702 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
|
50
|
1703 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
|
78
|
1704 } else {
|
|
1705 conf->upstream.max_temp_file_size =
|
|
1706 conf->upstream.max_temp_file_size_conf;
|
|
1707 }
|
50
|
1708
|
78
|
1709 if (conf->upstream.max_temp_file_size != 0
|
|
1710 && conf->upstream.max_temp_file_size < size)
|
50
|
1711 {
|
|
1712 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1713 "\"fastcgi_max_temp_file_size\" must be equal to zero to disable "
|
|
1714 "the temporary files usage or must be equal or bigger than "
|
288
|
1715 "maximum of the value of \"fastcgi_buffer_size\" and "
|
50
|
1716 "one of the \"fastcgi_buffers\"");
|
|
1717
|
|
1718 return NGX_CONF_ERROR;
|
|
1719 }
|
|
1720
|
|
1721
|
|
1722 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
|
|
1723 prev->upstream.next_upstream,
|
|
1724 (NGX_CONF_BITMASK_SET
|
|
1725 |NGX_HTTP_UPSTREAM_FT_ERROR
|
|
1726 |NGX_HTTP_UPSTREAM_FT_TIMEOUT));
|
|
1727
|
214
|
1728 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
|
|
1729 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
|
|
1730 |NGX_HTTP_UPSTREAM_FT_OFF;
|
|
1731 }
|
|
1732
|
50
|
1733 ngx_conf_merge_path_value(conf->upstream.temp_path,
|
|
1734 prev->upstream.temp_path,
|
|
1735 NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0,
|
|
1736 ngx_garbage_collector_temp_handler, cf);
|
|
1737
|
58
|
1738 ngx_conf_merge_value(conf->upstream.pass_request_headers,
|
|
1739 prev->upstream.pass_request_headers, 1);
|
|
1740 ngx_conf_merge_value(conf->upstream.pass_request_body,
|
|
1741 prev->upstream.pass_request_body, 1);
|
|
1742
|
206
|
1743 ngx_conf_merge_value(conf->upstream.intercept_errors,
|
|
1744 prev->upstream.intercept_errors, 0);
|
58
|
1745
|
306
|
1746 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL);
|
|
1747
|
56
|
1748
|
50
|
1749 ngx_conf_merge_str_value(conf->index, prev->index, "");
|
|
1750
|
198
|
1751 if (conf->upstream.hide_headers == NULL
|
|
1752 && conf->upstream.pass_headers == NULL)
|
|
1753 {
|
|
1754 conf->upstream.hide_headers = prev->upstream.hide_headers;
|
|
1755 conf->upstream.pass_headers = prev->upstream.pass_headers;
|
|
1756 conf->upstream.hide_headers_hash = prev->upstream.hide_headers_hash;
|
|
1757
|
|
1758 if (conf->upstream.hide_headers_hash.buckets) {
|
|
1759 goto peers;
|
|
1760 }
|
|
1761
|
|
1762 } else {
|
|
1763 if (conf->upstream.hide_headers == NULL) {
|
|
1764 conf->upstream.hide_headers = prev->upstream.hide_headers;
|
|
1765 }
|
|
1766
|
|
1767 if (conf->upstream.pass_headers == NULL) {
|
|
1768 conf->upstream.pass_headers = prev->upstream.pass_headers;
|
|
1769 }
|
|
1770 }
|
|
1771
|
|
1772 if (ngx_array_init(&hide_headers, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
|
|
1773 != NGX_OK)
|
|
1774 {
|
|
1775 return NGX_CONF_ERROR;
|
|
1776 }
|
|
1777
|
|
1778 for (header = ngx_http_fastcgi_hide_headers; header->len; header++) {
|
|
1779 hk = ngx_array_push(&hide_headers);
|
|
1780 if (hk == NULL) {
|
|
1781 return NGX_CONF_ERROR;
|
|
1782 }
|
|
1783
|
|
1784 hk->key = *header;
|
|
1785 hk->key_hash = ngx_hash_key_lc(header->data, header->len);
|
|
1786 hk->value = (void *) 1;
|
|
1787 }
|
|
1788
|
|
1789 if (conf->upstream.hide_headers) {
|
|
1790
|
|
1791 header = conf->upstream.hide_headers->elts;
|
|
1792
|
|
1793 for (i = 0; i < conf->upstream.hide_headers->nelts; i++) {
|
|
1794
|
|
1795 hk = hide_headers.elts;
|
|
1796
|
|
1797 for (j = 0; j < hide_headers.nelts; j++) {
|
|
1798 if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
|
|
1799 goto exist;
|
|
1800 }
|
|
1801 }
|
|
1802
|
|
1803 hk = ngx_array_push(&hide_headers);
|
|
1804 if (hk == NULL) {
|
|
1805 return NGX_CONF_ERROR;
|
|
1806 }
|
|
1807
|
|
1808 hk->key = header[i];
|
|
1809 hk->key_hash = ngx_hash_key_lc(header[i].data, header[i].len);
|
|
1810 hk->value = (void *) 1;
|
|
1811
|
|
1812 exist:
|
|
1813
|
|
1814 continue;
|
|
1815 }
|
|
1816 }
|
|
1817
|
|
1818 if (conf->upstream.pass_headers) {
|
|
1819
|
|
1820 hk = hide_headers.elts;
|
|
1821 header = conf->upstream.pass_headers->elts;
|
|
1822
|
|
1823 for (i = 0; i < conf->upstream.pass_headers->nelts; i++) {
|
|
1824
|
|
1825 for (j = 0; j < hide_headers.nelts; j++) {
|
|
1826
|
|
1827 if (hk[j].key.data == NULL) {
|
|
1828 continue;
|
|
1829 }
|
|
1830
|
|
1831 if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
|
|
1832 hk[j].key.data = NULL;
|
|
1833 break;
|
|
1834 }
|
|
1835 }
|
|
1836 }
|
|
1837 }
|
|
1838
|
|
1839 hash.hash = &conf->upstream.hide_headers_hash;
|
|
1840 hash.key = ngx_hash_key_lc;
|
|
1841 hash.max_size = 512;
|
244
|
1842 hash.bucket_size = ngx_align(64, ngx_cacheline_size);
|
198
|
1843 hash.name = "fastcgi_hide_headers_hash";
|
|
1844 hash.pool = cf->pool;
|
|
1845 hash.temp_pool = NULL;
|
|
1846
|
|
1847 if (ngx_hash_init(&hash, hide_headers.elts, hide_headers.nelts) != NGX_OK) {
|
|
1848 return NGX_CONF_ERROR;
|
|
1849 }
|
|
1850
|
|
1851 peers:
|
|
1852
|
260
|
1853 if (conf->upstream.upstream == NULL) {
|
|
1854 conf->upstream.upstream = prev->upstream.upstream;
|
178
|
1855 conf->upstream.schema = prev->upstream.schema;
|
56
|
1856 }
|
|
1857
|
58
|
1858 if (conf->params_source == NULL) {
|
122
|
1859 conf->flushes = prev->flushes;
|
58
|
1860 conf->params_len = prev->params_len;
|
|
1861 conf->params = prev->params;
|
122
|
1862 conf->params_source = prev->params_source;
|
58
|
1863
|
|
1864 if (conf->params_source == NULL) {
|
|
1865 return NGX_CONF_OK;
|
|
1866 }
|
|
1867 }
|
|
1868
|
|
1869 conf->params_len = ngx_array_create(cf->pool, 64, 1);
|
|
1870 if (conf->params_len == NULL) {
|
|
1871 return NGX_CONF_ERROR;
|
|
1872 }
|
122
|
1873
|
58
|
1874 conf->params = ngx_array_create(cf->pool, 512, 1);
|
|
1875 if (conf->params == NULL) {
|
|
1876 return NGX_CONF_ERROR;
|
|
1877 }
|
|
1878
|
|
1879 src = conf->params_source->elts;
|
|
1880 for (i = 0; i < conf->params_source->nelts; i++) {
|
|
1881
|
|
1882 if (ngx_http_script_variables_count(&src[i].value) == 0) {
|
|
1883 copy = ngx_array_push_n(conf->params_len,
|
|
1884 sizeof(ngx_http_script_copy_code_t));
|
|
1885 if (copy == NULL) {
|
|
1886 return NGX_CONF_ERROR;
|
|
1887 }
|
|
1888
|
|
1889 copy->code = (ngx_http_script_code_pt)
|
|
1890 ngx_http_script_copy_len_code;
|
|
1891 copy->len = src[i].key.len;
|
|
1892
|
|
1893
|
|
1894 copy = ngx_array_push_n(conf->params_len,
|
|
1895 sizeof(ngx_http_script_copy_code_t));
|
|
1896 if (copy == NULL) {
|
|
1897 return NGX_CONF_ERROR;
|
|
1898 }
|
|
1899
|
|
1900 copy->code = (ngx_http_script_code_pt)
|
|
1901 ngx_http_script_copy_len_code;
|
|
1902 copy->len = src[i].value.len;
|
|
1903
|
|
1904
|
|
1905 size = (sizeof(ngx_http_script_copy_code_t)
|
|
1906 + src[i].key.len + src[i].value.len
|
|
1907 + sizeof(uintptr_t) - 1)
|
|
1908 & ~(sizeof(uintptr_t) - 1);
|
|
1909
|
|
1910 copy = ngx_array_push_n(conf->params, size);
|
|
1911 if (copy == NULL) {
|
|
1912 return NGX_CONF_ERROR;
|
|
1913 }
|
126
|
1914
|
58
|
1915 copy->code = ngx_http_script_copy_code;
|
|
1916 copy->len = src[i].key.len + src[i].value.len;
|
|
1917
|
|
1918 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t);
|
|
1919
|
|
1920 p = ngx_cpymem(p, src[i].key.data, src[i].key.len);
|
|
1921 ngx_memcpy(p, src[i].value.data, src[i].value.len);
|
|
1922
|
|
1923 } else {
|
|
1924 copy = ngx_array_push_n(conf->params_len,
|
|
1925 sizeof(ngx_http_script_copy_code_t));
|
|
1926 if (copy == NULL) {
|
|
1927 return NGX_CONF_ERROR;
|
|
1928 }
|
|
1929
|
|
1930 copy->code = (ngx_http_script_code_pt)
|
|
1931 ngx_http_script_copy_len_code;
|
|
1932 copy->len = src[i].key.len;
|
|
1933
|
|
1934
|
|
1935 size = (sizeof(ngx_http_script_copy_code_t)
|
|
1936 + src[i].key.len + sizeof(uintptr_t) - 1)
|
|
1937 & ~(sizeof(uintptr_t) - 1);
|
|
1938
|
|
1939 copy = ngx_array_push_n(conf->params, size);
|
|
1940 if (copy == NULL) {
|
|
1941 return NGX_CONF_ERROR;
|
|
1942 }
|
126
|
1943
|
58
|
1944 copy->code = ngx_http_script_copy_code;
|
|
1945 copy->len = src[i].key.len;
|
|
1946
|
|
1947 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t);
|
|
1948 ngx_memcpy(p, src[i].key.data, src[i].key.len);
|
|
1949
|
|
1950
|
|
1951 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
|
1952
|
|
1953 sc.cf = cf;
|
|
1954 sc.source = &src[i].value;
|
122
|
1955 sc.flushes = &conf->flushes;
|
58
|
1956 sc.lengths = &conf->params_len;
|
|
1957 sc.values = &conf->params;
|
|
1958
|
|
1959 if (ngx_http_script_compile(&sc) != NGX_OK) {
|
|
1960 return NGX_CONF_ERROR;
|
|
1961 }
|
|
1962 }
|
|
1963
|
|
1964 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
|
|
1965 if (code == NULL) {
|
|
1966 return NGX_CONF_ERROR;
|
|
1967 }
|
|
1968
|
|
1969 *code = (uintptr_t) NULL;
|
|
1970
|
|
1971
|
|
1972 code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
|
|
1973 if (code == NULL) {
|
|
1974 return NGX_CONF_ERROR;
|
|
1975 }
|
|
1976
|
|
1977 *code = (uintptr_t) NULL;
|
|
1978 }
|
|
1979
|
|
1980 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
|
|
1981 if (code == NULL) {
|
|
1982 return NGX_CONF_ERROR;
|
|
1983 }
|
|
1984
|
|
1985 *code = (uintptr_t) NULL;
|
|
1986
|
50
|
1987 return NGX_CONF_OK;
|
|
1988 }
|
58
|
1989
|
|
1990
|
122
|
1991 static ngx_int_t
|
|
1992 ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r,
|
|
1993 ngx_http_variable_value_t *v, uintptr_t data)
|
58
|
1994 {
|
|
1995 u_char *p;
|
|
1996 ngx_http_fastcgi_loc_conf_t *flcf;
|
|
1997
|
284
|
1998 if (r->uri.len) {
|
|
1999 v->valid = 1;
|
|
2000 v->no_cachable = 0;
|
|
2001 v->not_found = 0;
|
|
2002
|
|
2003 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
|
|
2004
|
|
2005 if (r->uri.data[r->uri.len - 1] != '/') {
|
|
2006 v->len = r->uri.len;
|
|
2007 v->data = r->uri.data;
|
|
2008 return NGX_OK;
|
|
2009 }
|
|
2010
|
|
2011 v->len = r->uri.len + flcf->index.len;
|
|
2012
|
|
2013 v->data = ngx_palloc(r->pool, v->len);
|
|
2014 if (v->data == NULL) {
|
|
2015 return NGX_ERROR;
|
|
2016 }
|
|
2017
|
|
2018 p = ngx_copy(v->data, r->uri.data, r->uri.len);
|
|
2019 ngx_memcpy(p, flcf->index.data, flcf->index.len);
|
|
2020
|
|
2021 } else {
|
|
2022 v->len = 0;
|
|
2023 v->valid = 1;
|
|
2024 v->no_cachable = 0;
|
|
2025 v->not_found = 0;
|
|
2026 v->data = NULL;
|
|
2027
|
122
|
2028 return NGX_OK;
|
58
|
2029 }
|
|
2030
|
122
|
2031 return NGX_OK;
|
58
|
2032 }
|
|
2033
|
|
2034
|
|
2035 static char *
|
|
2036 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
2037 {
|
|
2038 ngx_http_fastcgi_loc_conf_t *lcf = conf;
|
|
2039
|
200
|
2040 ngx_url_t u;
|
58
|
2041 ngx_str_t *value;
|
|
2042 ngx_http_core_loc_conf_t *clcf;
|
|
2043
|
104
|
2044 if (lcf->upstream.schema.len) {
|
|
2045 return "is duplicate";
|
|
2046 }
|
|
2047
|
58
|
2048 value = cf->args->elts;
|
|
2049
|
200
|
2050 ngx_memzero(&u, sizeof(ngx_url_t));
|
|
2051
|
|
2052 u.url = value[1];
|
260
|
2053 u.no_resolve = 1;
|
|
2054
|
|
2055 lcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
|
|
2056 if (lcf->upstream.upstream == NULL) {
|
58
|
2057 return NGX_CONF_ERROR;
|
|
2058 }
|
|
2059
|
|
2060 lcf->upstream.schema.len = sizeof("fastcgi://") - 1;
|
|
2061 lcf->upstream.schema.data = (u_char *) "fastcgi://";
|
|
2062
|
|
2063 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
|
2064
|
|
2065 clcf->handler = ngx_http_fastcgi_handler;
|
|
2066
|
122
|
2067 lcf->upstream.location = clcf->name;
|
58
|
2068
|
|
2069 if (clcf->name.data[clcf->name.len - 1] == '/') {
|
|
2070 clcf->auto_redirect = 1;
|
|
2071 }
|
|
2072
|
|
2073 return NGX_CONF_OK;
|
|
2074 }
|
|
2075
|
|
2076
|
|
2077 static char *
|
|
2078 ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data)
|
|
2079 {
|
|
2080 #if (NGX_FREEBSD)
|
|
2081 ssize_t *np = data;
|
|
2082
|
222
|
2083 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) {
|
58
|
2084 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
2085 "\"fastcgi_send_lowat\" must be less than %d "
|
|
2086 "(sysctl net.inet.tcp.sendspace)",
|
|
2087 ngx_freebsd_net_inet_tcp_sendspace);
|
|
2088
|
|
2089 return NGX_CONF_ERROR;
|
|
2090 }
|
|
2091
|
|
2092 #elif !(NGX_HAVE_SO_SNDLOWAT)
|
|
2093 ssize_t *np = data;
|
|
2094
|
|
2095 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
|
2096 "\"fastcgi_send_lowat\" is not supported, ignored");
|
|
2097
|
|
2098 *np = 0;
|
|
2099
|
|
2100 #endif
|
|
2101
|
|
2102 return NGX_CONF_OK;
|
|
2103 }
|
260
|
2104
|
|
2105
|
|
2106 static char *
|
|
2107 ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf,
|
|
2108 ngx_command_t *cmd, void *conf)
|
|
2109 {
|
|
2110 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
2111 "\"fastcgi_upstream_max_fails\" is not supported, "
|
|
2112 "use the \"max_fails\" parameter of the \"server\" directive ",
|
|
2113 "inside the \"upstream\" block");
|
|
2114
|
|
2115 return NGX_CONF_ERROR;
|
|
2116 }
|
|
2117
|
|
2118
|
|
2119 static char *
|
|
2120 ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf,
|
|
2121 ngx_command_t *cmd, void *conf)
|
|
2122 {
|
|
2123 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
2124 "\"fastcgi_upstream_fail_timeout\" is not supported, "
|
|
2125 "use the \"fail_timeout\" parameter of the \"server\" directive ",
|
|
2126 "inside the \"upstream\" block");
|
|
2127
|
|
2128 return NGX_CONF_ERROR;
|
|
2129 }
|