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