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