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