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