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