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