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