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