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