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