Mercurial > hg > nginx
annotate src/http/modules/ngx_http_scgi_module.c @ 5411:5483d9e77b32
Limit req: fixed "nodelay" parsing.
Previously arguments starting with "nodelay" were considered valid,
e.g. "limit_req ... nodelayFOO;".
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 02 Oct 2013 15:07:17 +0400 |
parents | 1a070e89b97a |
children | 43ccaf8e8728 |
rev | line source |
---|---|
3637 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
3637 | 5 * Copyright (C) Manlio Perillo (manlio.perillo@gmail.com) |
6 */ | |
7 | |
8 | |
9 #include <ngx_config.h> | |
10 #include <ngx_core.h> | |
11 #include <ngx_http.h> | |
12 | |
13 | |
14 typedef struct { | |
15 ngx_http_upstream_conf_t upstream; | |
16 | |
17 ngx_array_t *flushes; | |
18 ngx_array_t *params_len; | |
19 ngx_array_t *params; | |
20 ngx_array_t *params_source; | |
21 | |
22 ngx_hash_t headers_hash; | |
23 ngx_uint_t header_params; | |
24 | |
25 ngx_array_t *scgi_lengths; | |
26 ngx_array_t *scgi_values; | |
27 | |
28 #if (NGX_HTTP_CACHE) | |
29 ngx_http_complex_value_t cache_key; | |
30 #endif | |
31 } ngx_http_scgi_loc_conf_t; | |
32 | |
33 | |
34 static ngx_int_t ngx_http_scgi_eval(ngx_http_request_t *r, | |
35 ngx_http_scgi_loc_conf_t *scf); | |
36 static ngx_int_t ngx_http_scgi_create_request(ngx_http_request_t *r); | |
37 static ngx_int_t ngx_http_scgi_reinit_request(ngx_http_request_t *r); | |
38 static ngx_int_t ngx_http_scgi_process_status_line(ngx_http_request_t *r); | |
39 static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); | |
40 static void ngx_http_scgi_abort_request(ngx_http_request_t *r); | |
41 static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc); | |
42 | |
43 static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf); | |
44 static char *ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, | |
45 void *child); | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
46 static ngx_int_t ngx_http_scgi_merge_params(ngx_conf_t *cf, |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
47 ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_loc_conf_t *prev); |
3637 | 48 |
49 static char *ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
50 static char *ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, | |
51 void *conf); | |
52 | |
53 #if (NGX_HTTP_CACHE) | |
54 static ngx_int_t ngx_http_scgi_create_key(ngx_http_request_t *r); | |
55 static char *ngx_http_scgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, | |
56 void *conf); | |
57 static char *ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, | |
58 void *conf); | |
59 #endif | |
60 | |
61 | |
62 static ngx_conf_bitmask_t ngx_http_scgi_next_upstream_masks[] = { | |
63 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | |
64 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | |
65 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, | |
66 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, | |
67 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, | |
5231
05c53652e7b4
Upstream: http_403 support in proxy_next_upstream (and friends).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5080
diff
changeset
|
68 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 }, |
3637 | 69 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, |
70 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING }, | |
71 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, | |
72 { ngx_null_string, 0 } | |
73 }; | |
74 | |
75 | |
76 ngx_module_t ngx_http_scgi_module; | |
77 | |
78 | |
79 static ngx_command_t ngx_http_scgi_commands[] = { | |
80 | |
81 { ngx_string("scgi_pass"), | |
82 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, | |
83 ngx_http_scgi_pass, | |
84 NGX_HTTP_LOC_CONF_OFFSET, | |
85 0, | |
86 NULL }, | |
87 | |
88 { ngx_string("scgi_store"), | |
89 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
90 ngx_http_scgi_store, | |
91 NGX_HTTP_LOC_CONF_OFFSET, | |
92 0, | |
93 NULL }, | |
94 | |
95 { ngx_string("scgi_store_access"), | |
96 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, | |
97 ngx_conf_set_access_slot, | |
98 NGX_HTTP_LOC_CONF_OFFSET, | |
99 offsetof(ngx_http_scgi_loc_conf_t, upstream.store_access), | |
100 NULL }, | |
101 | |
4157
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
102 { ngx_string("scgi_buffering"), |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
103 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
104 ngx_conf_set_flag_slot, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
105 NGX_HTTP_LOC_CONF_OFFSET, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
106 offsetof(ngx_http_scgi_loc_conf_t, upstream.buffering), |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
107 NULL }, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
108 |
3637 | 109 { ngx_string("scgi_ignore_client_abort"), |
110 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
111 ngx_conf_set_flag_slot, | |
112 NGX_HTTP_LOC_CONF_OFFSET, | |
113 offsetof(ngx_http_scgi_loc_conf_t, upstream.ignore_client_abort), | |
114 NULL }, | |
115 | |
116 { ngx_string("scgi_bind"), | |
117 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
118 ngx_http_upstream_bind_set_slot, | |
119 NGX_HTTP_LOC_CONF_OFFSET, | |
120 offsetof(ngx_http_scgi_loc_conf_t, upstream.local), | |
121 NULL }, | |
122 | |
123 { ngx_string("scgi_connect_timeout"), | |
124 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
125 ngx_conf_set_msec_slot, | |
126 NGX_HTTP_LOC_CONF_OFFSET, | |
127 offsetof(ngx_http_scgi_loc_conf_t, upstream.connect_timeout), | |
128 NULL }, | |
129 | |
130 { ngx_string("scgi_send_timeout"), | |
131 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
132 ngx_conf_set_msec_slot, | |
133 NGX_HTTP_LOC_CONF_OFFSET, | |
134 offsetof(ngx_http_scgi_loc_conf_t, upstream.send_timeout), | |
135 NULL }, | |
136 | |
137 { ngx_string("scgi_buffer_size"), | |
138 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
139 ngx_conf_set_size_slot, | |
140 NGX_HTTP_LOC_CONF_OFFSET, | |
141 offsetof(ngx_http_scgi_loc_conf_t, upstream.buffer_size), | |
142 NULL }, | |
143 | |
144 { ngx_string("scgi_pass_request_headers"), | |
145 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
146 ngx_conf_set_flag_slot, | |
147 NGX_HTTP_LOC_CONF_OFFSET, | |
148 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_request_headers), | |
149 NULL }, | |
150 | |
151 { ngx_string("scgi_pass_request_body"), | |
152 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
153 ngx_conf_set_flag_slot, | |
154 NGX_HTTP_LOC_CONF_OFFSET, | |
155 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_request_body), | |
156 NULL }, | |
157 | |
158 { ngx_string("scgi_intercept_errors"), | |
159 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
160 ngx_conf_set_flag_slot, | |
161 NGX_HTTP_LOC_CONF_OFFSET, | |
162 offsetof(ngx_http_scgi_loc_conf_t, upstream.intercept_errors), | |
163 NULL }, | |
164 | |
165 { ngx_string("scgi_read_timeout"), | |
166 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
167 ngx_conf_set_msec_slot, | |
168 NGX_HTTP_LOC_CONF_OFFSET, | |
169 offsetof(ngx_http_scgi_loc_conf_t, upstream.read_timeout), | |
170 NULL }, | |
171 | |
172 { ngx_string("scgi_buffers"), | |
173 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
174 ngx_conf_set_bufs_slot, | |
175 NGX_HTTP_LOC_CONF_OFFSET, | |
176 offsetof(ngx_http_scgi_loc_conf_t, upstream.bufs), | |
177 NULL }, | |
178 | |
179 { ngx_string("scgi_busy_buffers_size"), | |
180 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
181 ngx_conf_set_size_slot, | |
182 NGX_HTTP_LOC_CONF_OFFSET, | |
183 offsetof(ngx_http_scgi_loc_conf_t, upstream.busy_buffers_size_conf), | |
184 NULL }, | |
185 | |
186 #if (NGX_HTTP_CACHE) | |
187 | |
188 { ngx_string("scgi_cache"), | |
3729 | 189 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 190 ngx_http_scgi_cache, |
191 NGX_HTTP_LOC_CONF_OFFSET, | |
192 0, | |
193 NULL }, | |
194 | |
195 { ngx_string("scgi_cache_key"), | |
3729 | 196 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 197 ngx_http_scgi_cache_key, |
198 NGX_HTTP_LOC_CONF_OFFSET, | |
199 0, | |
200 NULL }, | |
201 | |
202 { ngx_string("scgi_cache_path"), | |
203 NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE, | |
204 ngx_http_file_cache_set_slot, | |
205 0, | |
206 0, | |
207 &ngx_http_scgi_module }, | |
208 | |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
209 { ngx_string("scgi_cache_bypass"), |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
210 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:
3693
diff
changeset
|
211 ngx_http_set_predicate_slot, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
212 NGX_HTTP_LOC_CONF_OFFSET, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
213 offsetof(ngx_http_scgi_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:
3693
diff
changeset
|
214 NULL }, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
215 |
3637 | 216 { ngx_string("scgi_no_cache"), |
217 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
|
218 ngx_http_set_predicate_slot, |
3637 | 219 NGX_HTTP_LOC_CONF_OFFSET, |
220 offsetof(ngx_http_scgi_loc_conf_t, upstream.no_cache), | |
221 NULL }, | |
222 | |
223 { ngx_string("scgi_cache_valid"), | |
224 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
225 ngx_http_file_cache_valid_set_slot, | |
226 NGX_HTTP_LOC_CONF_OFFSET, | |
227 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_valid), | |
228 NULL }, | |
229 | |
230 { ngx_string("scgi_cache_min_uses"), | |
231 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
232 ngx_conf_set_num_slot, | |
233 NGX_HTTP_LOC_CONF_OFFSET, | |
234 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_min_uses), | |
235 NULL }, | |
236 | |
237 { ngx_string("scgi_cache_use_stale"), | |
238 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
239 ngx_conf_set_bitmask_slot, | |
240 NGX_HTTP_LOC_CONF_OFFSET, | |
241 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_use_stale), | |
242 &ngx_http_scgi_next_upstream_masks }, | |
243 | |
244 { ngx_string("scgi_cache_methods"), | |
245 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
246 ngx_conf_set_bitmask_slot, | |
247 NGX_HTTP_LOC_CONF_OFFSET, | |
248 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_methods), | |
249 &ngx_http_upstream_cache_method_mask }, | |
250 | |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
251 { ngx_string("scgi_cache_lock"), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
252 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
253 ngx_conf_set_flag_slot, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
254 NGX_HTTP_LOC_CONF_OFFSET, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
255 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
256 NULL }, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
257 |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
258 { ngx_string("scgi_cache_lock_timeout"), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
259 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
260 ngx_conf_set_msec_slot, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
261 NGX_HTTP_LOC_CONF_OFFSET, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
262 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_timeout), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
263 NULL }, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
264 |
3637 | 265 #endif |
266 | |
267 { ngx_string("scgi_temp_path"), | |
268 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
269 ngx_conf_set_path_slot, | |
270 NGX_HTTP_LOC_CONF_OFFSET, | |
271 offsetof(ngx_http_scgi_loc_conf_t, upstream.temp_path), | |
272 NULL }, | |
273 | |
274 { ngx_string("scgi_max_temp_file_size"), | |
275 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
276 ngx_conf_set_size_slot, | |
277 NGX_HTTP_LOC_CONF_OFFSET, | |
278 offsetof(ngx_http_scgi_loc_conf_t, upstream.max_temp_file_size_conf), | |
279 NULL }, | |
280 | |
281 { ngx_string("scgi_temp_file_write_size"), | |
282 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
283 ngx_conf_set_size_slot, | |
284 NGX_HTTP_LOC_CONF_OFFSET, | |
285 offsetof(ngx_http_scgi_loc_conf_t, upstream.temp_file_write_size_conf), | |
286 NULL }, | |
287 | |
288 { ngx_string("scgi_next_upstream"), | |
289 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
290 ngx_conf_set_bitmask_slot, | |
291 NGX_HTTP_LOC_CONF_OFFSET, | |
292 offsetof(ngx_http_scgi_loc_conf_t, upstream.next_upstream), | |
293 &ngx_http_scgi_next_upstream_masks }, | |
294 | |
295 { ngx_string("scgi_param"), | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
296 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
297 ngx_http_upstream_param_set_slot, |
3637 | 298 NGX_HTTP_LOC_CONF_OFFSET, |
299 offsetof(ngx_http_scgi_loc_conf_t, params_source), | |
300 NULL }, | |
301 | |
302 { ngx_string("scgi_pass_header"), | |
3729 | 303 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 304 ngx_conf_set_str_array_slot, |
305 NGX_HTTP_LOC_CONF_OFFSET, | |
306 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_headers), | |
307 NULL }, | |
308 | |
309 { ngx_string("scgi_hide_header"), | |
3729 | 310 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 311 ngx_conf_set_str_array_slot, |
312 NGX_HTTP_LOC_CONF_OFFSET, | |
313 offsetof(ngx_http_scgi_loc_conf_t, upstream.hide_headers), | |
314 NULL }, | |
315 | |
316 { ngx_string("scgi_ignore_headers"), | |
317 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
318 ngx_conf_set_bitmask_slot, | |
319 NGX_HTTP_LOC_CONF_OFFSET, | |
320 offsetof(ngx_http_scgi_loc_conf_t, upstream.ignore_headers), | |
3667
12bd9e26fadb
use shared ngx_http_upstream_ignore_headers_masks[]
Igor Sysoev <igor@sysoev.ru>
parents:
3637
diff
changeset
|
321 &ngx_http_upstream_ignore_headers_masks }, |
3637 | 322 |
323 ngx_null_command | |
324 }; | |
325 | |
326 | |
327 static ngx_http_module_t ngx_http_scgi_module_ctx = { | |
328 NULL, /* preconfiguration */ | |
329 NULL, /* postconfiguration */ | |
330 | |
331 NULL, /* create main configuration */ | |
332 NULL, /* init main configuration */ | |
333 | |
334 NULL, /* create server configuration */ | |
335 NULL, /* merge server configuration */ | |
336 | |
337 ngx_http_scgi_create_loc_conf, /* create location configuration */ | |
338 ngx_http_scgi_merge_loc_conf /* merge location configuration */ | |
339 }; | |
340 | |
341 | |
342 ngx_module_t ngx_http_scgi_module = { | |
343 NGX_MODULE_V1, | |
344 &ngx_http_scgi_module_ctx, /* module context */ | |
345 ngx_http_scgi_commands, /* module directives */ | |
346 NGX_HTTP_MODULE, /* module type */ | |
347 NULL, /* init master */ | |
348 NULL, /* init module */ | |
349 NULL, /* init process */ | |
350 NULL, /* init thread */ | |
351 NULL, /* exit thread */ | |
352 NULL, /* exit process */ | |
353 NULL, /* exit master */ | |
354 NGX_MODULE_V1_PADDING | |
355 }; | |
356 | |
357 | |
358 static ngx_str_t ngx_http_scgi_hide_headers[] = { | |
359 ngx_string("Status"), | |
360 ngx_string("X-Accel-Expires"), | |
361 ngx_string("X-Accel-Redirect"), | |
362 ngx_string("X-Accel-Limit-Rate"), | |
363 ngx_string("X-Accel-Buffering"), | |
364 ngx_string("X-Accel-Charset"), | |
365 ngx_null_string | |
366 }; | |
367 | |
368 | |
369 #if (NGX_HTTP_CACHE) | |
370 | |
371 static ngx_keyval_t ngx_http_scgi_cache_headers[] = { | |
372 { ngx_string("HTTP_IF_MODIFIED_SINCE"), ngx_string("") }, | |
373 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") }, | |
374 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") }, | |
375 { ngx_string("HTTP_IF_MATCH"), ngx_string("") }, | |
376 { ngx_string("HTTP_RANGE"), ngx_string("") }, | |
377 { ngx_string("HTTP_IF_RANGE"), ngx_string("") }, | |
378 { ngx_null_string, ngx_null_string } | |
379 }; | |
380 | |
381 #endif | |
382 | |
383 | |
384 static ngx_path_init_t ngx_http_scgi_temp_path = { | |
385 ngx_string(NGX_HTTP_SCGI_TEMP_PATH), { 1, 2, 0 } | |
386 }; | |
387 | |
388 | |
389 static ngx_int_t | |
390 ngx_http_scgi_handler(ngx_http_request_t *r) | |
391 { | |
392 ngx_int_t rc; | |
393 ngx_http_status_t *status; | |
394 ngx_http_upstream_t *u; | |
395 ngx_http_scgi_loc_conf_t *scf; | |
396 | |
397 if (ngx_http_upstream_create(r) != NGX_OK) { | |
398 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
399 } | |
400 | |
401 status = ngx_pcalloc(r->pool, sizeof(ngx_http_status_t)); | |
402 if (status == NULL) { | |
403 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
404 } | |
405 | |
406 ngx_http_set_ctx(r, status, ngx_http_scgi_module); | |
407 | |
408 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module); | |
409 | |
410 if (scf->scgi_lengths) { | |
411 if (ngx_http_scgi_eval(r, scf) != NGX_OK) { | |
412 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
413 } | |
414 } | |
415 | |
416 u = r->upstream; | |
417 | |
418 ngx_str_set(&u->schema, "scgi://"); | |
419 u->output.tag = (ngx_buf_tag_t) &ngx_http_scgi_module; | |
420 | |
421 u->conf = &scf->upstream; | |
422 | |
423 #if (NGX_HTTP_CACHE) | |
424 u->create_key = ngx_http_scgi_create_key; | |
425 #endif | |
426 u->create_request = ngx_http_scgi_create_request; | |
427 u->reinit_request = ngx_http_scgi_reinit_request; | |
428 u->process_header = ngx_http_scgi_process_status_line; | |
429 u->abort_request = ngx_http_scgi_abort_request; | |
430 u->finalize_request = ngx_http_scgi_finalize_request; | |
4615
adcd60233817
Added r->state reset on fastcgi/scgi/uwsgi request start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
431 r->state = 0; |
3637 | 432 |
4157
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
433 u->buffering = scf->upstream.buffering; |
3637 | 434 |
435 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); | |
436 if (u->pipe == NULL) { | |
437 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
438 } | |
439 | |
440 u->pipe->input_filter = ngx_event_pipe_copy_input_filter; | |
441 u->pipe->input_ctx = r; | |
442 | |
443 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); | |
444 | |
445 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
446 return rc; | |
447 } | |
448 | |
449 return NGX_DONE; | |
450 } | |
451 | |
452 | |
453 static ngx_int_t | |
454 ngx_http_scgi_eval(ngx_http_request_t *r, ngx_http_scgi_loc_conf_t * scf) | |
455 { | |
456 ngx_url_t url; | |
457 ngx_http_upstream_t *u; | |
458 | |
459 ngx_memzero(&url, sizeof(ngx_url_t)); | |
460 | |
461 if (ngx_http_script_run(r, &url.url, scf->scgi_lengths->elts, 0, | |
462 scf->scgi_values->elts) | |
463 == NULL) | |
464 { | |
465 return NGX_ERROR; | |
466 } | |
467 | |
468 url.no_resolve = 1; | |
469 | |
470 if (ngx_parse_url(r->pool, &url) != NGX_OK) { | |
471 if (url.err) { | |
472 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
473 "%s in upstream \"%V\"", url.err, &url.url); | |
474 } | |
475 | |
476 return NGX_ERROR; | |
477 } | |
478 | |
479 u = r->upstream; | |
480 | |
481 u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t)); | |
482 if (u->resolved == NULL) { | |
483 return NGX_ERROR; | |
484 } | |
485 | |
486 if (url.addrs && url.addrs[0].sockaddr) { | |
487 u->resolved->sockaddr = url.addrs[0].sockaddr; | |
488 u->resolved->socklen = url.addrs[0].socklen; | |
489 u->resolved->naddrs = 1; | |
490 u->resolved->host = url.addrs[0].name; | |
491 | |
492 } else { | |
493 u->resolved->host = url.host; | |
494 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:
3731
diff
changeset
|
495 u->resolved->no_port = url.no_port; |
3637 | 496 } |
497 | |
498 return NGX_OK; | |
499 } | |
500 | |
501 | |
502 #if (NGX_HTTP_CACHE) | |
503 | |
504 static ngx_int_t | |
505 ngx_http_scgi_create_key(ngx_http_request_t *r) | |
506 { | |
507 ngx_str_t *key; | |
508 ngx_http_scgi_loc_conf_t *scf; | |
509 | |
510 key = ngx_array_push(&r->cache->keys); | |
511 if (key == NULL) { | |
512 return NGX_ERROR; | |
513 } | |
514 | |
515 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module); | |
516 | |
517 if (ngx_http_complex_value(r, &scf->cache_key, key) != NGX_OK) { | |
518 return NGX_ERROR; | |
519 } | |
520 | |
521 return NGX_OK; | |
522 } | |
523 | |
524 #endif | |
525 | |
526 | |
527 static ngx_int_t | |
528 ngx_http_scgi_create_request(ngx_http_request_t *r) | |
529 { | |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
530 off_t content_length_n; |
3637 | 531 u_char ch, *key, *val, *lowcase_key; |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
532 size_t len, key_len, val_len, allocated; |
3637 | 533 ngx_buf_t *b; |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
534 ngx_str_t content_length; |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
535 ngx_uint_t i, n, hash, skip_empty, header_params; |
3637 | 536 ngx_chain_t *cl, *body; |
537 ngx_list_part_t *part; | |
538 ngx_table_elt_t *header, **ignored; | |
539 ngx_http_script_code_pt code; | |
540 ngx_http_script_engine_t e, le; | |
541 ngx_http_scgi_loc_conf_t *scf; | |
542 ngx_http_script_len_code_pt lcode; | |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
543 u_char buffer[NGX_OFF_T_LEN]; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
544 |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
545 content_length_n = 0; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
546 body = r->upstream->request_bufs; |
3637 | 547 |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
548 while (body) { |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
549 content_length_n += ngx_buf_size(body->buf); |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
550 body = body->next; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
551 } |
3637 | 552 |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
553 content_length.data = buffer; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
554 content_length.len = ngx_sprintf(buffer, "%O", content_length_n) - buffer; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
555 |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
556 len = sizeof("CONTENT_LENGTH") + content_length.len + 1; |
3637 | 557 |
558 header_params = 0; | |
559 ignored = NULL; | |
560 | |
561 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module); | |
562 | |
563 if (scf->params_len) { | |
564 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
565 | |
566 ngx_http_script_flush_no_cacheable_variables(r, scf->flushes); | |
567 le.flushed = 1; | |
568 | |
569 le.ip = scf->params_len->elts; | |
570 le.request = r; | |
571 | |
572 while (*(uintptr_t *) le.ip) { | |
573 | |
574 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
575 key_len = lcode(&le); |
3637 | 576 |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
577 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
578 skip_empty = lcode(&le); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
579 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
580 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
3637 | 581 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
582 } | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
583 le.ip += sizeof(uintptr_t); |
4294
56cb2255735a
Fixed incorrect counting the length of headers in a SCGI request.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
584 |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
585 if (skip_empty && val_len == 0) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
586 continue; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
587 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
588 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
589 len += key_len + val_len + 1; |
3637 | 590 } |
591 } | |
592 | |
593 if (scf->upstream.pass_request_headers) { | |
594 | |
595 allocated = 0; | |
596 lowcase_key = NULL; | |
597 | |
598 if (scf->header_params) { | |
4015
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
599 n = 0; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
600 part = &r->headers_in.headers.part; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
601 |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
602 while (part) { |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
603 n += part->nelts; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
604 part = part->next; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
605 } |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
606 |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
607 ignored = ngx_palloc(r->pool, n * sizeof(void *)); |
3637 | 608 if (ignored == NULL) { |
609 return NGX_ERROR; | |
610 } | |
611 } | |
612 | |
613 part = &r->headers_in.headers.part; | |
614 header = part->elts; | |
615 | |
616 for (i = 0; /* void */; i++) { | |
617 | |
618 if (i >= part->nelts) { | |
619 if (part->next == NULL) { | |
620 break; | |
621 } | |
622 | |
623 part = part->next; | |
624 header = part->elts; | |
625 i = 0; | |
626 } | |
627 | |
628 if (scf->header_params) { | |
629 if (allocated < header[i].key.len) { | |
630 allocated = header[i].key.len + 16; | |
631 lowcase_key = ngx_pnalloc(r->pool, allocated); | |
632 if (lowcase_key == NULL) { | |
633 return NGX_ERROR; | |
634 } | |
635 } | |
636 | |
637 hash = 0; | |
638 | |
639 for (n = 0; n < header[i].key.len; n++) { | |
640 ch = header[i].key.data[n]; | |
641 | |
642 if (ch >= 'A' && ch <= 'Z') { | |
643 ch |= 0x20; | |
644 | |
645 } else if (ch == '-') { | |
646 ch = '_'; | |
647 } | |
648 | |
649 hash = ngx_hash(hash, ch); | |
650 lowcase_key[n] = ch; | |
651 } | |
652 | |
653 if (ngx_hash_find(&scf->headers_hash, hash, lowcase_key, n)) { | |
654 ignored[header_params++] = &header[i]; | |
655 continue; | |
656 } | |
657 } | |
658 | |
659 len += sizeof("HTTP_") - 1 + header[i].key.len + 1 | |
660 + header[i].value.len + 1; | |
661 } | |
662 } | |
663 | |
664 /* netstring: "length:" + packet + "," */ | |
665 | |
666 b = ngx_create_temp_buf(r->pool, NGX_SIZE_T_LEN + 1 + len + 1); | |
667 if (b == NULL) { | |
668 return NGX_ERROR; | |
669 } | |
670 | |
671 cl = ngx_alloc_chain_link(r->pool); | |
672 if (cl == NULL) { | |
673 return NGX_ERROR; | |
674 } | |
675 | |
676 cl->buf = b; | |
677 | |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
678 b->last = ngx_sprintf(b->last, "%ui:CONTENT_LENGTH%Z%V%Z", |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
679 len, &content_length); |
3637 | 680 |
681 if (scf->params_len) { | |
682 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
683 | |
684 e.ip = scf->params->elts; | |
685 e.pos = b->last; | |
686 e.request = r; | |
687 e.flushed = 1; | |
688 | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
689 le.ip = scf->params_len->elts; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
690 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
691 while (*(uintptr_t *) le.ip) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
692 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
693 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
694 lcode(&le); /* key length */ |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
695 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
696 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
697 skip_empty = lcode(&le); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
698 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
699 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
700 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
701 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
702 le.ip += sizeof(uintptr_t); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
703 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
704 if (skip_empty && val_len == 0) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
705 e.skip = 1; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
706 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
707 while (*(uintptr_t *) e.ip) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
708 code = *(ngx_http_script_code_pt *) e.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
709 code((ngx_http_script_engine_t *) &e); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
710 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
711 e.ip += sizeof(uintptr_t); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
712 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
713 e.skip = 0; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
714 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
715 continue; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
716 } |
3637 | 717 |
718 #if (NGX_DEBUG) | |
719 key = e.pos; | |
720 #endif | |
721 code = *(ngx_http_script_code_pt *) e.ip; | |
722 code((ngx_http_script_engine_t *) & e); | |
723 | |
724 #if (NGX_DEBUG) | |
725 val = e.pos; | |
726 #endif | |
727 while (*(uintptr_t *) e.ip) { | |
728 code = *(ngx_http_script_code_pt *) e.ip; | |
729 code((ngx_http_script_engine_t *) &e); | |
730 } | |
731 *e.pos++ = '\0'; | |
732 e.ip += sizeof(uintptr_t); | |
733 | |
734 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
735 "scgi param: \"%s: %s\"", key, val); | |
736 } | |
737 | |
738 b->last = e.pos; | |
739 } | |
740 | |
741 if (scf->upstream.pass_request_headers) { | |
742 | |
743 part = &r->headers_in.headers.part; | |
744 header = part->elts; | |
745 | |
746 for (i = 0; /* void */; i++) { | |
747 | |
748 if (i >= part->nelts) { | |
749 if (part->next == NULL) { | |
750 break; | |
751 } | |
752 | |
753 part = part->next; | |
754 header = part->elts; | |
755 i = 0; | |
756 } | |
757 | |
758 for (n = 0; n < header_params; n++) { | |
759 if (&header[i] == ignored[n]) { | |
760 goto next; | |
761 } | |
762 } | |
763 | |
764 key = b->last; | |
765 b->last = ngx_cpymem(key, "HTTP_", sizeof("HTTP_") - 1); | |
766 | |
767 for (n = 0; n < header[i].key.len; n++) { | |
768 ch = header[i].key.data[n]; | |
769 | |
770 if (ch >= 'a' && ch <= 'z') { | |
771 ch &= ~0x20; | |
772 | |
773 } else if (ch == '-') { | |
774 ch = '_'; | |
775 } | |
776 | |
777 *b->last++ = ch; | |
778 } | |
779 | |
780 *b->last++ = (u_char) 0; | |
781 | |
782 val = b->last; | |
783 b->last = ngx_copy(val, header[i].value.data, header[i].value.len); | |
784 *b->last++ = (u_char) 0; | |
785 | |
786 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
787 "scgi param: \"%s: %s\"", key, val); | |
788 | |
789 next: | |
790 | |
791 continue; | |
792 } | |
793 } | |
794 | |
795 *b->last++ = (u_char) ','; | |
796 | |
797 if (scf->upstream.pass_request_body) { | |
798 body = r->upstream->request_bufs; | |
799 r->upstream->request_bufs = cl; | |
800 | |
801 while (body) { | |
802 b = ngx_alloc_buf(r->pool); | |
803 if (b == NULL) { | |
804 return NGX_ERROR; | |
805 } | |
806 | |
807 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); | |
808 | |
809 cl->next = ngx_alloc_chain_link(r->pool); | |
810 if (cl->next == NULL) { | |
811 return NGX_ERROR; | |
812 } | |
813 | |
814 cl = cl->next; | |
815 cl->buf = b; | |
816 | |
817 body = body->next; | |
818 } | |
819 | |
820 } else { | |
821 r->upstream->request_bufs = cl; | |
822 } | |
823 | |
824 cl->next = NULL; | |
825 | |
826 return NGX_OK; | |
827 } | |
828 | |
829 | |
830 static ngx_int_t | |
831 ngx_http_scgi_reinit_request(ngx_http_request_t *r) | |
832 { | |
833 ngx_http_status_t *status; | |
834 | |
835 status = ngx_http_get_module_ctx(r, ngx_http_scgi_module); | |
836 | |
837 if (status == NULL) { | |
838 return NGX_OK; | |
839 } | |
840 | |
841 status->code = 0; | |
842 status->count = 0; | |
843 status->start = NULL; | |
844 status->end = NULL; | |
845 | |
846 r->upstream->process_header = ngx_http_scgi_process_status_line; | |
4615
adcd60233817
Added r->state reset on fastcgi/scgi/uwsgi request start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
847 r->state = 0; |
3637 | 848 |
849 return NGX_OK; | |
850 } | |
851 | |
852 | |
853 static ngx_int_t | |
854 ngx_http_scgi_process_status_line(ngx_http_request_t *r) | |
855 { | |
856 size_t len; | |
857 ngx_int_t rc; | |
858 ngx_http_status_t *status; | |
859 ngx_http_upstream_t *u; | |
860 | |
861 status = ngx_http_get_module_ctx(r, ngx_http_scgi_module); | |
862 | |
863 if (status == NULL) { | |
864 return NGX_ERROR; | |
865 } | |
866 | |
867 u = r->upstream; | |
868 | |
869 rc = ngx_http_parse_status_line(r, &u->buffer, status); | |
870 | |
871 if (rc == NGX_AGAIN) { | |
872 return rc; | |
873 } | |
874 | |
875 if (rc == NGX_ERROR) { | |
876 u->process_header = ngx_http_scgi_process_header; | |
877 return ngx_http_scgi_process_header(r); | |
878 } | |
879 | |
880 if (u->state) { | |
881 u->state->status = status->code; | |
882 } | |
883 | |
884 u->headers_in.status_n = status->code; | |
885 | |
886 len = status->end - status->start; | |
887 u->headers_in.status_line.len = len; | |
888 | |
889 u->headers_in.status_line.data = ngx_pnalloc(r->pool, len); | |
890 if (u->headers_in.status_line.data == NULL) { | |
891 return NGX_ERROR; | |
892 } | |
893 | |
894 ngx_memcpy(u->headers_in.status_line.data, status->start, len); | |
895 | |
896 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
897 "http scgi status %ui \"%V\"", | |
898 u->headers_in.status_n, &u->headers_in.status_line); | |
899 | |
900 u->process_header = ngx_http_scgi_process_header; | |
901 | |
902 return ngx_http_scgi_process_header(r); | |
903 } | |
904 | |
905 | |
906 static ngx_int_t | |
907 ngx_http_scgi_process_header(ngx_http_request_t *r) | |
908 { | |
909 ngx_str_t *status_line; | |
910 ngx_int_t rc, status; | |
911 ngx_table_elt_t *h; | |
912 ngx_http_upstream_t *u; | |
913 ngx_http_upstream_header_t *hh; | |
914 ngx_http_upstream_main_conf_t *umcf; | |
915 | |
916 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); | |
917 | |
918 for ( ;; ) { | |
919 | |
920 rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1); | |
921 | |
922 if (rc == NGX_OK) { | |
923 | |
924 /* a header line has been parsed successfully */ | |
925 | |
926 h = ngx_list_push(&r->upstream->headers_in.headers); | |
927 if (h == NULL) { | |
928 return NGX_ERROR; | |
929 } | |
930 | |
931 h->hash = r->header_hash; | |
932 | |
933 h->key.len = r->header_name_end - r->header_name_start; | |
934 h->value.len = r->header_end - r->header_start; | |
935 | |
936 h->key.data = ngx_pnalloc(r->pool, | |
937 h->key.len + 1 + h->value.len + 1 | |
938 + h->key.len); | |
939 if (h->key.data == NULL) { | |
940 return NGX_ERROR; | |
941 } | |
942 | |
943 h->value.data = h->key.data + h->key.len + 1; | |
944 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; | |
945 | |
4529
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
946 ngx_memcpy(h->key.data, r->header_name_start, h->key.len); |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
947 h->key.data[h->key.len] = '\0'; |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
948 ngx_memcpy(h->value.data, r->header_start, h->value.len); |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
949 h->value.data[h->value.len] = '\0'; |
3637 | 950 |
951 if (h->key.len == r->lowcase_index) { | |
952 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
953 | |
954 } else { | |
955 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); | |
956 } | |
957 | |
958 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, | |
959 h->lowcase_key, h->key.len); | |
960 | |
961 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
962 return NGX_ERROR; | |
963 } | |
964 | |
965 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
966 "http scgi header: \"%V: %V\"", &h->key, &h->value); | |
967 | |
968 continue; | |
969 } | |
970 | |
971 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
972 | |
973 /* a whole header has been parsed successfully */ | |
974 | |
975 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
976 "http scgi header done"); | |
977 | |
4371
16ebad9447ee
Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4331
diff
changeset
|
978 u = r->upstream; |
16ebad9447ee
Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4331
diff
changeset
|
979 |
16ebad9447ee
Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4331
diff
changeset
|
980 if (u->headers_in.status_n) { |
5078
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
981 goto done; |
3637 | 982 } |
983 | |
984 if (u->headers_in.status) { | |
985 status_line = &u->headers_in.status->value; | |
986 | |
987 status = ngx_atoi(status_line->data, 3); | |
988 if (status == NGX_ERROR) { | |
989 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
990 "upstream sent invalid status \"%V\"", | |
991 status_line); | |
992 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
993 } | |
994 | |
995 u->headers_in.status_n = status; | |
996 u->headers_in.status_line = *status_line; | |
997 | |
998 } else if (u->headers_in.location) { | |
999 u->headers_in.status_n = 302; | |
1000 ngx_str_set(&u->headers_in.status_line, | |
1001 "302 Moved Temporarily"); | |
1002 | |
1003 } else { | |
1004 u->headers_in.status_n = 200; | |
1005 ngx_str_set(&u->headers_in.status_line, "200 OK"); | |
1006 } | |
1007 | |
1008 if (u->state) { | |
1009 u->state->status = u->headers_in.status_n; | |
1010 } | |
1011 | |
5078
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1012 done: |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1013 |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1014 if (u->headers_in.status_n == NGX_HTTP_SWITCHING_PROTOCOLS |
5080
8da37c1b22a4
Trailing whitespace fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5078
diff
changeset
|
1015 && r->headers_in.upgrade) |
5078
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1016 { |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1017 u->upgrade = 1; |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1018 } |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1019 |
3637 | 1020 return NGX_OK; |
1021 } | |
1022 | |
1023 if (rc == NGX_AGAIN) { | |
1024 return NGX_AGAIN; | |
1025 } | |
1026 | |
1027 /* there was error while a header line parsing */ | |
1028 | |
1029 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1030 "upstream sent invalid header"); | |
1031 | |
1032 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1033 } | |
1034 } | |
1035 | |
1036 | |
1037 static void | |
1038 ngx_http_scgi_abort_request(ngx_http_request_t *r) | |
1039 { | |
1040 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1041 "abort http scgi request"); | |
1042 | |
1043 return; | |
1044 } | |
1045 | |
1046 | |
1047 static void | |
1048 ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
1049 { | |
1050 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1051 "finalize http scgi request"); | |
1052 | |
1053 return; | |
1054 } | |
1055 | |
1056 | |
1057 static void * | |
1058 ngx_http_scgi_create_loc_conf(ngx_conf_t *cf) | |
1059 { | |
1060 ngx_http_scgi_loc_conf_t *conf; | |
1061 | |
1062 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_scgi_loc_conf_t)); | |
1063 if (conf == NULL) { | |
1064 return NULL; | |
1065 } | |
1066 | |
1067 conf->upstream.store = NGX_CONF_UNSET; | |
1068 conf->upstream.store_access = NGX_CONF_UNSET_UINT; | |
1069 conf->upstream.buffering = NGX_CONF_UNSET; | |
1070 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; | |
1071 | |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1072 conf->upstream.local = NGX_CONF_UNSET_PTR; |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1073 |
3637 | 1074 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
1075 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
1076 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC; | |
1077 | |
1078 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; | |
1079 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; | |
1080 | |
1081 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
1082 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; | |
1083 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; | |
1084 | |
1085 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
1086 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
1087 | |
1088 #if (NGX_HTTP_CACHE) | |
1089 conf->upstream.cache = NGX_CONF_UNSET_PTR; | |
1090 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:
3693
diff
changeset
|
1091 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; |
3693
e3bcc2f4c418
fix scgi_no_cache and uwsgi_no_cache initialization
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
1092 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; |
3637 | 1093 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1094 conf->upstream.cache_lock = NGX_CONF_UNSET; |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1095 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; |
3637 | 1096 #endif |
1097 | |
1098 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; | |
1099 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; | |
1100 | |
1101 conf->upstream.intercept_errors = NGX_CONF_UNSET; | |
1102 | |
1103 /* "scgi_cyclic_temp_file" is disabled */ | |
1104 conf->upstream.cyclic_temp_file = 0; | |
1105 | |
4157
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1106 conf->upstream.change_buffering = 1; |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1107 |
3976
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
1108 ngx_str_set(&conf->upstream.module, "scgi"); |
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
1109 |
3637 | 1110 return conf; |
1111 } | |
1112 | |
1113 | |
1114 static char * | |
1115 ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
1116 { | |
1117 ngx_http_scgi_loc_conf_t *prev = parent; | |
1118 ngx_http_scgi_loc_conf_t *conf = child; | |
1119 | |
1120 size_t size; | |
1121 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
|
1122 ngx_http_core_loc_conf_t *clcf; |
3637 | 1123 |
1124 if (conf->upstream.store != 0) { | |
1125 ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0); | |
1126 | |
1127 if (conf->upstream.store_lengths == NULL) { | |
1128 conf->upstream.store_lengths = prev->upstream.store_lengths; | |
1129 conf->upstream.store_values = prev->upstream.store_values; | |
1130 } | |
1131 } | |
1132 | |
1133 ngx_conf_merge_uint_value(conf->upstream.store_access, | |
1134 prev->upstream.store_access, 0600); | |
1135 | |
1136 ngx_conf_merge_value(conf->upstream.buffering, | |
1137 prev->upstream.buffering, 1); | |
1138 | |
1139 ngx_conf_merge_value(conf->upstream.ignore_client_abort, | |
1140 prev->upstream.ignore_client_abort, 0); | |
1141 | |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1142 ngx_conf_merge_ptr_value(conf->upstream.local, |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1143 prev->upstream.local, NULL); |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1144 |
3637 | 1145 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
1146 prev->upstream.connect_timeout, 60000); | |
1147 | |
1148 ngx_conf_merge_msec_value(conf->upstream.send_timeout, | |
1149 prev->upstream.send_timeout, 60000); | |
1150 | |
1151 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
1152 prev->upstream.read_timeout, 60000); | |
1153 | |
1154 ngx_conf_merge_size_value(conf->upstream.send_lowat, | |
1155 prev->upstream.send_lowat, 0); | |
1156 | |
1157 ngx_conf_merge_size_value(conf->upstream.buffer_size, | |
1158 prev->upstream.buffer_size, | |
1159 (size_t) ngx_pagesize); | |
1160 | |
1161 | |
1162 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, | |
1163 8, ngx_pagesize); | |
1164 | |
1165 if (conf->upstream.bufs.num < 2) { | |
1166 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1167 "there must be at least 2 \"scgi_buffers\""); | |
1168 return NGX_CONF_ERROR; | |
1169 } | |
1170 | |
1171 | |
1172 size = conf->upstream.buffer_size; | |
1173 if (size < conf->upstream.bufs.size) { | |
1174 size = conf->upstream.bufs.size; | |
1175 } | |
1176 | |
1177 | |
1178 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, | |
1179 prev->upstream.busy_buffers_size_conf, | |
1180 NGX_CONF_UNSET_SIZE); | |
1181 | |
1182 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { | |
1183 conf->upstream.busy_buffers_size = 2 * size; | |
1184 } else { | |
1185 conf->upstream.busy_buffers_size = | |
1186 conf->upstream.busy_buffers_size_conf; | |
1187 } | |
1188 | |
1189 if (conf->upstream.busy_buffers_size < size) { | |
1190 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1191 "\"scgi_busy_buffers_size\" must be equal to or greater " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1192 "than the maximum of the value of \"scgi_buffer_size\" and " |
3637 | 1193 "one of the \"scgi_buffers\""); |
1194 | |
1195 return NGX_CONF_ERROR; | |
1196 } | |
1197 | |
1198 if (conf->upstream.busy_buffers_size | |
1199 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
1200 { | |
1201 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1202 "\"scgi_busy_buffers_size\" must be less than " | |
1203 "the size of all \"scgi_buffers\" minus one buffer"); | |
1204 | |
1205 return NGX_CONF_ERROR; | |
1206 } | |
1207 | |
1208 | |
1209 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, | |
1210 prev->upstream.temp_file_write_size_conf, | |
1211 NGX_CONF_UNSET_SIZE); | |
1212 | |
1213 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { | |
1214 conf->upstream.temp_file_write_size = 2 * size; | |
1215 } else { | |
1216 conf->upstream.temp_file_write_size = | |
1217 conf->upstream.temp_file_write_size_conf; | |
1218 } | |
1219 | |
1220 if (conf->upstream.temp_file_write_size < size) { | |
1221 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1222 "\"scgi_temp_file_write_size\" must be equal to or greater than " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1223 "the maximum of the value of \"scgi_buffer_size\" and " |
3637 | 1224 "one of the \"scgi_buffers\""); |
1225 | |
1226 return NGX_CONF_ERROR; | |
1227 } | |
1228 | |
1229 | |
1230 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, | |
1231 prev->upstream.max_temp_file_size_conf, | |
1232 NGX_CONF_UNSET_SIZE); | |
1233 | |
1234 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { | |
1235 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; | |
1236 } else { | |
1237 conf->upstream.max_temp_file_size = | |
1238 conf->upstream.max_temp_file_size_conf; | |
1239 } | |
1240 | |
1241 if (conf->upstream.max_temp_file_size != 0 | |
1242 && conf->upstream.max_temp_file_size < size) { | |
1243 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1244 "\"scgi_max_temp_file_size\" must be equal to zero to disable " | |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1245 "temporary files usage or must be equal to or greater than " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1246 "the maximum of the value of \"scgi_buffer_size\" and " |
3637 | 1247 "one of the \"scgi_buffers\""); |
1248 | |
1249 return NGX_CONF_ERROR; | |
1250 } | |
1251 | |
1252 | |
1253 ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers, | |
1254 prev->upstream.ignore_headers, | |
1255 NGX_CONF_BITMASK_SET); | |
1256 | |
1257 | |
1258 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, | |
1259 prev->upstream.next_upstream, | |
1260 (NGX_CONF_BITMASK_SET | |
1261 |NGX_HTTP_UPSTREAM_FT_ERROR | |
1262 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
1263 | |
1264 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { | |
1265 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
1266 |NGX_HTTP_UPSTREAM_FT_OFF; | |
1267 } | |
1268 | |
1269 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, | |
1270 prev->upstream.temp_path, | |
1271 &ngx_http_scgi_temp_path) | |
1272 != NGX_OK) | |
1273 { | |
1274 return NGX_CONF_ERROR; | |
1275 } | |
1276 | |
1277 #if (NGX_HTTP_CACHE) | |
1278 | |
1279 ngx_conf_merge_ptr_value(conf->upstream.cache, | |
1280 prev->upstream.cache, NULL); | |
1281 | |
1282 if (conf->upstream.cache && conf->upstream.cache->data == NULL) { | |
1283 ngx_shm_zone_t *shm_zone; | |
1284 | |
1285 shm_zone = conf->upstream.cache; | |
1286 | |
1287 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1288 "\"scgi_cache\" zone \"%V\" is unknown", | |
1289 &shm_zone->shm.name); | |
1290 | |
1291 return NGX_CONF_ERROR; | |
1292 } | |
1293 | |
1294 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses, | |
1295 prev->upstream.cache_min_uses, 1); | |
1296 | |
1297 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale, | |
1298 prev->upstream.cache_use_stale, | |
1299 (NGX_CONF_BITMASK_SET | |
1300 |NGX_HTTP_UPSTREAM_FT_OFF)); | |
1301 | |
1302 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) { | |
1303 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET | |
1304 |NGX_HTTP_UPSTREAM_FT_OFF; | |
1305 } | |
1306 | |
4401
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
1307 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_ERROR) { |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
1308 conf->upstream.cache_use_stale |= NGX_HTTP_UPSTREAM_FT_NOLIVE; |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
1309 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
1310 |
3637 | 1311 if (conf->upstream.cache_methods == 0) { |
1312 conf->upstream.cache_methods = prev->upstream.cache_methods; | |
1313 } | |
1314 | |
1315 conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD; | |
1316 | |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
1317 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:
3693
diff
changeset
|
1318 prev->upstream.cache_bypass, NULL); |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
1319 |
3637 | 1320 ngx_conf_merge_ptr_value(conf->upstream.no_cache, |
1321 prev->upstream.no_cache, NULL); | |
1322 | |
1323 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, | |
1324 prev->upstream.cache_valid, NULL); | |
1325 | |
1326 if (conf->cache_key.value.data == NULL) { | |
1327 conf->cache_key = prev->cache_key; | |
1328 } | |
1329 | |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1330 ngx_conf_merge_value(conf->upstream.cache_lock, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1331 prev->upstream.cache_lock, 0); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1332 |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1333 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1334 prev->upstream.cache_lock_timeout, 5000); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1335 |
3637 | 1336 #endif |
1337 | |
1338 ngx_conf_merge_value(conf->upstream.pass_request_headers, | |
1339 prev->upstream.pass_request_headers, 1); | |
1340 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
1341 prev->upstream.pass_request_body, 1); | |
1342 | |
1343 ngx_conf_merge_value(conf->upstream.intercept_errors, | |
1344 prev->upstream.intercept_errors, 0); | |
1345 | |
1346 hash.max_size = 512; | |
1347 hash.bucket_size = ngx_align(64, ngx_cacheline_size); | |
1348 hash.name = "scgi_hide_headers_hash"; | |
1349 | |
1350 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:
3668
diff
changeset
|
1351 &prev->upstream, ngx_http_scgi_hide_headers, &hash) |
3637 | 1352 != NGX_OK) |
1353 { | |
1354 return NGX_CONF_ERROR; | |
1355 } | |
1356 | |
1357 if (conf->upstream.upstream == NULL) { | |
1358 conf->upstream.upstream = prev->upstream.upstream; | |
1359 } | |
1360 | |
1361 if (conf->scgi_lengths == NULL) { | |
1362 conf->scgi_lengths = prev->scgi_lengths; | |
1363 conf->scgi_values = prev->scgi_values; | |
1364 } | |
1365 | |
3731
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1366 if (conf->upstream.upstream || conf->scgi_lengths) { |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1367 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
|
1368 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
|
1369 clcf->handler = ngx_http_scgi_handler; |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1370 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1371 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1372 |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1373 if (ngx_http_scgi_merge_params(cf, conf, prev) != NGX_OK) { |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1374 return NGX_CONF_ERROR; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1375 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1376 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1377 return NGX_CONF_OK; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1378 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1379 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1380 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1381 static ngx_int_t |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1382 ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf, |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1383 ngx_http_scgi_loc_conf_t *prev) |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1384 { |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1385 u_char *p; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1386 size_t size; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1387 uintptr_t *code; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1388 ngx_uint_t i, nsrc; |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1389 ngx_array_t headers_names; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1390 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1391 ngx_array_t params_merged; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1392 #endif |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1393 ngx_hash_key_t *hk; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1394 ngx_hash_init_t hash; |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1395 ngx_http_upstream_param_t *src; |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1396 ngx_http_script_compile_t sc; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1397 ngx_http_script_copy_code_t *copy; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1398 |
3637 | 1399 if (conf->params_source == NULL) { |
1400 conf->params_source = prev->params_source; | |
1401 | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1402 if (prev->headers_hash.buckets |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1403 #if (NGX_HTTP_CACHE) |
4522 | 1404 && ((conf->upstream.cache == NULL) |
1405 == (prev->upstream.cache == NULL)) | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1406 #endif |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1407 ) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1408 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1409 conf->flushes = prev->flushes; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1410 conf->params_len = prev->params_len; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1411 conf->params = prev->params; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1412 conf->headers_hash = prev->headers_hash; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1413 conf->header_params = prev->header_params; |
3637 | 1414 |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1415 return NGX_OK; |
3637 | 1416 } |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1417 } |
3637 | 1418 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1419 if (conf->params_source == NULL |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1420 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1421 && (conf->upstream.cache == NULL) |
3637 | 1422 #endif |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1423 ) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1424 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1425 conf->headers_hash.buckets = (void *) 1; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1426 return NGX_OK; |
3637 | 1427 } |
1428 | |
1429 conf->params_len = ngx_array_create(cf->pool, 64, 1); | |
1430 if (conf->params_len == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1431 return NGX_ERROR; |
3637 | 1432 } |
1433 | |
1434 conf->params = ngx_array_create(cf->pool, 512, 1); | |
1435 if (conf->params == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1436 return NGX_ERROR; |
3637 | 1437 } |
1438 | |
1439 if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) | |
1440 != NGX_OK) | |
1441 { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1442 return NGX_ERROR; |
3637 | 1443 } |
1444 | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1445 if (conf->params_source) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1446 src = conf->params_source->elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1447 nsrc = conf->params_source->nelts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1448 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1449 } else { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1450 src = NULL; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1451 nsrc = 0; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1452 } |
3637 | 1453 |
1454 #if (NGX_HTTP_CACHE) | |
1455 | |
1456 if (conf->upstream.cache) { | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1457 ngx_keyval_t *h; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1458 ngx_http_upstream_param_t *s; |
3637 | 1459 |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1460 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1461 sizeof(ngx_http_upstream_param_t)) |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1462 != NGX_OK) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1463 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1464 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1465 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1466 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1467 for (i = 0; i < nsrc; i++) { |
3637 | 1468 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1469 s = ngx_array_push(¶ms_merged); |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1470 if (s == NULL) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1471 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1472 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1473 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1474 *s = src[i]; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1475 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1476 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1477 h = ngx_http_scgi_cache_headers; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1478 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1479 while (h->key.len) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1480 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1481 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1482 nsrc = params_merged.nelts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1483 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1484 for (i = 0; i < nsrc; i++) { |
3637 | 1485 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
1486 goto next; | |
1487 } | |
1488 } | |
1489 | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1490 s = ngx_array_push(¶ms_merged); |
3637 | 1491 if (s == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1492 return NGX_ERROR; |
3637 | 1493 } |
1494 | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1495 s->key = h->key; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1496 s->value = h->value; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1497 s->skip_empty = 0; |
3637 | 1498 |
1499 next: | |
1500 | |
1501 h++; | |
1502 } | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1503 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1504 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1505 nsrc = params_merged.nelts; |
3637 | 1506 } |
1507 | |
1508 #endif | |
1509 | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1510 for (i = 0; i < nsrc; i++) { |
3637 | 1511 |
1512 if (src[i].key.len > sizeof("HTTP_") - 1 | |
1513 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) | |
1514 { | |
1515 hk = ngx_array_push(&headers_names); | |
1516 if (hk == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1517 return NGX_ERROR; |
3637 | 1518 } |
1519 | |
1520 hk->key.len = src[i].key.len - 5; | |
1521 hk->key.data = src[i].key.data + 5; | |
1522 hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len); | |
1523 hk->value = (void *) 1; | |
1524 | |
1525 if (src[i].value.len == 0) { | |
1526 continue; | |
1527 } | |
1528 } | |
1529 | |
1530 copy = ngx_array_push_n(conf->params_len, | |
1531 sizeof(ngx_http_script_copy_code_t)); | |
1532 if (copy == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1533 return NGX_ERROR; |
3637 | 1534 } |
1535 | |
1536 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; | |
1537 copy->len = src[i].key.len + 1; | |
1538 | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1539 copy = ngx_array_push_n(conf->params_len, |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1540 sizeof(ngx_http_script_copy_code_t)); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1541 if (copy == NULL) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1542 return NGX_ERROR; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1543 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1544 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1545 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1546 copy->len = src[i].skip_empty; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1547 |
3637 | 1548 |
1549 size = (sizeof(ngx_http_script_copy_code_t) | |
1550 + src[i].key.len + 1 + sizeof(uintptr_t) - 1) | |
1551 & ~(sizeof(uintptr_t) - 1); | |
1552 | |
1553 copy = ngx_array_push_n(conf->params, size); | |
1554 if (copy == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1555 return NGX_ERROR; |
3637 | 1556 } |
1557 | |
1558 copy->code = ngx_http_script_copy_code; | |
1559 copy->len = src[i].key.len + 1; | |
1560 | |
1561 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
1562 (void) ngx_cpystrn(p, src[i].key.data, src[i].key.len + 1); | |
1563 | |
1564 | |
1565 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
1566 | |
1567 sc.cf = cf; | |
1568 sc.source = &src[i].value; | |
1569 sc.flushes = &conf->flushes; | |
1570 sc.lengths = &conf->params_len; | |
1571 sc.values = &conf->params; | |
1572 | |
1573 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1574 return NGX_ERROR; |
3637 | 1575 } |
1576 | |
1577 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
1578 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1579 return NGX_ERROR; |
3637 | 1580 } |
1581 | |
1582 *code = (uintptr_t) NULL; | |
1583 | |
1584 | |
1585 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); | |
1586 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1587 return NGX_ERROR; |
3637 | 1588 } |
1589 | |
1590 *code = (uintptr_t) NULL; | |
1591 } | |
1592 | |
1593 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
1594 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1595 return NGX_ERROR; |
3637 | 1596 } |
1597 | |
1598 *code = (uintptr_t) NULL; | |
1599 | |
1600 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); | |
1601 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1602 return NGX_ERROR; |
3637 | 1603 } |
1604 | |
1605 *code = (uintptr_t) NULL; | |
1606 | |
1607 conf->header_params = headers_names.nelts; | |
1608 | |
1609 hash.hash = &conf->headers_hash; | |
1610 hash.key = ngx_hash_key_lc; | |
1611 hash.max_size = 512; | |
1612 hash.bucket_size = 64; | |
1613 hash.name = "scgi_params_hash"; | |
1614 hash.pool = cf->pool; | |
1615 hash.temp_pool = NULL; | |
1616 | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1617 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); |
3637 | 1618 } |
1619 | |
1620 | |
1621 static char * | |
1622 ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1623 { | |
1624 ngx_http_scgi_loc_conf_t *scf = conf; | |
1625 | |
1626 ngx_url_t u; | |
1627 ngx_str_t *value, *url; | |
1628 ngx_uint_t n; | |
1629 ngx_http_core_loc_conf_t *clcf; | |
1630 ngx_http_script_compile_t sc; | |
1631 | |
1632 if (scf->upstream.upstream || scf->scgi_lengths) { | |
1633 return "is duplicate"; | |
1634 } | |
1635 | |
1636 clcf = ngx_http_conf_get_module_loc_conf (cf, ngx_http_core_module); | |
1637 clcf->handler = ngx_http_scgi_handler; | |
1638 | |
1639 value = cf->args->elts; | |
1640 | |
1641 url = &value[1]; | |
1642 | |
1643 n = ngx_http_script_variables_count(url); | |
1644 | |
1645 if (n) { | |
1646 | |
1647 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
1648 | |
1649 sc.cf = cf; | |
1650 sc.source = url; | |
1651 sc.lengths = &scf->scgi_lengths; | |
1652 sc.values = &scf->scgi_values; | |
1653 sc.variables = n; | |
1654 sc.complete_lengths = 1; | |
1655 sc.complete_values = 1; | |
1656 | |
1657 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
1658 return NGX_CONF_ERROR; | |
1659 } | |
1660 | |
1661 return NGX_CONF_OK; | |
1662 } | |
1663 | |
1664 ngx_memzero(&u, sizeof(ngx_url_t)); | |
1665 | |
1666 u.url = value[1]; | |
1667 u.no_resolve = 1; | |
1668 | |
1669 scf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); | |
1670 if (scf->upstream.upstream == NULL) { | |
1671 return NGX_CONF_ERROR; | |
1672 } | |
1673 | |
1674 if (clcf->name.data[clcf->name.len - 1] == '/') { | |
1675 clcf->auto_redirect = 1; | |
1676 } | |
1677 | |
1678 return NGX_CONF_OK; | |
1679 } | |
1680 | |
1681 | |
1682 static char * | |
1683 ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1684 { | |
1685 ngx_http_scgi_loc_conf_t *scf = conf; | |
1686 | |
1687 ngx_str_t *value; | |
1688 ngx_http_script_compile_t sc; | |
1689 | |
1690 if (scf->upstream.store != NGX_CONF_UNSET || scf->upstream.store_lengths) { | |
1691 return "is duplicate"; | |
1692 } | |
1693 | |
1694 value = cf->args->elts; | |
1695 | |
1696 if (ngx_strcmp(value[1].data, "off") == 0) { | |
1697 scf->upstream.store = 0; | |
1698 return NGX_CONF_OK; | |
1699 } | |
1700 | |
1701 #if (NGX_HTTP_CACHE) | |
1702 | |
1703 if (scf->upstream.cache != NGX_CONF_UNSET_PTR | |
1704 && scf->upstream.cache != NULL) | |
1705 { | |
1706 return "is incompatible with \"scgi_cache\""; | |
1707 } | |
1708 | |
1709 #endif | |
1710 | |
1711 if (ngx_strcmp(value[1].data, "on") == 0) { | |
1712 scf->upstream.store = 1; | |
1713 return NGX_CONF_OK; | |
1714 } | |
1715 | |
1716 /* include the terminating '\0' into script */ | |
1717 value[1].len++; | |
1718 | |
1719 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
1720 | |
1721 sc.cf = cf; | |
1722 sc.source = &value[1]; | |
1723 sc.lengths = &scf->upstream.store_lengths; | |
1724 sc.values = &scf->upstream.store_values; | |
1725 sc.variables = ngx_http_script_variables_count(&value[1]);; | |
1726 sc.complete_lengths = 1; | |
1727 sc.complete_values = 1; | |
1728 | |
1729 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
1730 return NGX_CONF_ERROR; | |
1731 } | |
1732 | |
1733 return NGX_CONF_OK; | |
1734 } | |
1735 | |
1736 | |
1737 #if (NGX_HTTP_CACHE) | |
1738 | |
1739 static char * | |
1740 ngx_http_scgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1741 { | |
1742 ngx_http_scgi_loc_conf_t *scf = conf; | |
1743 | |
1744 ngx_str_t *value; | |
1745 | |
1746 value = cf->args->elts; | |
1747 | |
1748 if (scf->upstream.cache != NGX_CONF_UNSET_PTR) { | |
1749 return "is duplicate"; | |
1750 } | |
1751 | |
1752 if (ngx_strcmp(value[1].data, "off") == 0) { | |
1753 scf->upstream.cache = NULL; | |
1754 return NGX_CONF_OK; | |
1755 } | |
1756 | |
1757 if (scf->upstream.store > 0 || scf->upstream.store_lengths) { | |
1758 return "is incompatible with \"scgi_store\""; | |
1759 } | |
1760 | |
1761 scf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, | |
1762 &ngx_http_scgi_module); | |
1763 if (scf->upstream.cache == NULL) { | |
1764 return NGX_CONF_ERROR; | |
1765 } | |
1766 | |
1767 return NGX_CONF_OK; | |
1768 } | |
1769 | |
1770 | |
1771 static char * | |
1772 ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1773 { | |
1774 ngx_http_scgi_loc_conf_t *scf = conf; | |
1775 | |
1776 ngx_str_t *value; | |
1777 ngx_http_compile_complex_value_t ccv; | |
1778 | |
1779 value = cf->args->elts; | |
1780 | |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4929
diff
changeset
|
1781 if (scf->cache_key.value.data) { |
3637 | 1782 return "is duplicate"; |
1783 } | |
1784 | |
1785 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
1786 | |
1787 ccv.cf = cf; | |
1788 ccv.value = &value[1]; | |
1789 ccv.complex_value = &scf->cache_key; | |
1790 | |
1791 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
1792 return NGX_CONF_ERROR; | |
1793 } | |
1794 | |
1795 return NGX_CONF_OK; | |
1796 } | |
1797 | |
1798 #endif |