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