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