0
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
|
4 */
|
|
5
|
|
6
|
|
7 #include <ngx_config.h>
|
|
8 #include <ngx_core.h>
|
|
9 #include <ngx_http.h>
|
|
10 #include <ngx_http_proxy_handler.h>
|
|
11
|
|
12
|
|
13 static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r);
|
50
|
14 #if 0
|
26
|
15 static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p);
|
50
|
16 #endif
|
0
|
17
|
28
|
18 static size_t ngx_http_proxy_log_proxy_state_getlen(ngx_http_request_t *r,
|
|
19 uintptr_t data);
|
0
|
20 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r,
|
28
|
21 u_char *buf,
|
|
22 ngx_http_log_op_t *op);
|
|
23
|
|
24 #if 0
|
0
|
25 static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r,
|
|
26 u_char *buf, uintptr_t data);
|
|
27 static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf,
|
|
28 uintptr_t data);
|
28
|
29 #endif
|
0
|
30
|
28
|
31 static ngx_int_t ngx_http_proxy_add_log_formats(ngx_conf_t *cf);
|
0
|
32 static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf);
|
|
33 static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
|
|
34 void *parent, void *child);
|
|
35
|
|
36 static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
37 void *conf);
|
|
38
|
34
|
39 static char *ngx_http_proxy_set_x_var(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
40 void *conf);
|
2
|
41 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data);
|
|
42
|
|
43 static ngx_conf_post_t ngx_http_proxy_lowat_post =
|
|
44 { ngx_http_proxy_lowat_check } ;
|
|
45
|
0
|
46
|
|
47 static ngx_conf_bitmask_t next_upstream_masks[] = {
|
|
48 { ngx_string("error"), NGX_HTTP_PROXY_FT_ERROR },
|
|
49 { ngx_string("timeout"), NGX_HTTP_PROXY_FT_TIMEOUT },
|
|
50 { ngx_string("invalid_header"), NGX_HTTP_PROXY_FT_INVALID_HEADER },
|
|
51 { ngx_string("http_500"), NGX_HTTP_PROXY_FT_HTTP_500 },
|
|
52 { ngx_string("http_404"), NGX_HTTP_PROXY_FT_HTTP_404 },
|
|
53 { ngx_null_string, 0 }
|
|
54 };
|
|
55
|
|
56
|
|
57 static ngx_conf_bitmask_t use_stale_masks[] = {
|
|
58 { ngx_string("error"), NGX_HTTP_PROXY_FT_ERROR },
|
|
59 { ngx_string("timeout"), NGX_HTTP_PROXY_FT_TIMEOUT },
|
|
60 { ngx_string("invalid_header"), NGX_HTTP_PROXY_FT_INVALID_HEADER },
|
|
61 { ngx_string("http_500"), NGX_HTTP_PROXY_FT_HTTP_500 },
|
|
62 { ngx_string("busy_lock"), NGX_HTTP_PROXY_FT_BUSY_LOCK },
|
|
63 { ngx_string("max_waiting"), NGX_HTTP_PROXY_FT_MAX_WAITING },
|
|
64 { ngx_null_string, 0 }
|
|
65 };
|
|
66
|
|
67
|
|
68 static ngx_conf_num_bounds_t ngx_http_proxy_lm_factor_bounds = {
|
|
69 ngx_conf_check_num_bounds, 0, 100
|
|
70 };
|
|
71
|
|
72
|
|
73 static ngx_command_t ngx_http_proxy_commands[] = {
|
|
74
|
|
75 { ngx_string("proxy_pass"),
|
|
76 NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
77 ngx_http_proxy_set_pass,
|
|
78 NGX_HTTP_LOC_CONF_OFFSET,
|
|
79 0,
|
|
80 NULL },
|
|
81
|
|
82 { ngx_string("proxy_connect_timeout"),
|
|
83 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
84 ngx_conf_set_msec_slot,
|
|
85 NGX_HTTP_LOC_CONF_OFFSET,
|
|
86 offsetof(ngx_http_proxy_loc_conf_t, connect_timeout),
|
|
87 NULL },
|
|
88
|
|
89 { ngx_string("proxy_send_timeout"),
|
|
90 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
91 ngx_conf_set_msec_slot,
|
|
92 NGX_HTTP_LOC_CONF_OFFSET,
|
|
93 offsetof(ngx_http_proxy_loc_conf_t, send_timeout),
|
|
94 NULL },
|
|
95
|
2
|
96 { ngx_string("proxy_send_lowat"),
|
|
97 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
98 ngx_conf_set_size_slot,
|
|
99 NGX_HTTP_LOC_CONF_OFFSET,
|
|
100 offsetof(ngx_http_proxy_loc_conf_t, send_lowat),
|
|
101 &ngx_http_proxy_lowat_post },
|
|
102
|
0
|
103 { ngx_string("proxy_preserve_host"),
|
|
104 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
105 ngx_conf_set_flag_slot,
|
|
106 NGX_HTTP_LOC_CONF_OFFSET,
|
|
107 offsetof(ngx_http_proxy_loc_conf_t, preserve_host),
|
|
108 NULL },
|
|
109
|
54
|
110 { ngx_string("proxy_pass_unparsed_uri"),
|
|
111 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
112 ngx_conf_set_flag_slot,
|
|
113 NGX_HTTP_LOC_CONF_OFFSET,
|
|
114 offsetof(ngx_http_proxy_loc_conf_t, pass_unparsed_uri),
|
|
115 NULL },
|
|
116
|
6
|
117 { ngx_string("proxy_set_x_url"),
|
|
118 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
119 ngx_conf_set_flag_slot,
|
|
120 NGX_HTTP_LOC_CONF_OFFSET,
|
|
121 offsetof(ngx_http_proxy_loc_conf_t, set_x_url),
|
|
122 NULL },
|
|
123
|
0
|
124 { ngx_string("proxy_set_x_real_ip"),
|
|
125 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
126 ngx_conf_set_flag_slot,
|
|
127 NGX_HTTP_LOC_CONF_OFFSET,
|
|
128 offsetof(ngx_http_proxy_loc_conf_t, set_x_real_ip),
|
|
129 NULL },
|
|
130
|
34
|
131 { ngx_string("proxy_set_x_var"),
|
|
132 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
133 ngx_http_proxy_set_x_var,
|
|
134 NGX_HTTP_LOC_CONF_OFFSET,
|
|
135 0,
|
|
136 NULL },
|
|
137
|
0
|
138 { ngx_string("proxy_add_x_forwarded_for"),
|
|
139 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
140 ngx_conf_set_flag_slot,
|
|
141 NGX_HTTP_LOC_CONF_OFFSET,
|
|
142 offsetof(ngx_http_proxy_loc_conf_t, add_x_forwarded_for),
|
|
143 NULL },
|
|
144
|
|
145 { ngx_string("proxy_header_buffer_size"),
|
|
146 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
147 ngx_conf_set_size_slot,
|
|
148 NGX_HTTP_LOC_CONF_OFFSET,
|
|
149 offsetof(ngx_http_proxy_loc_conf_t, header_buffer_size),
|
|
150 NULL },
|
|
151
|
|
152 { ngx_string("proxy_read_timeout"),
|
|
153 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
154 ngx_conf_set_msec_slot,
|
|
155 NGX_HTTP_LOC_CONF_OFFSET,
|
|
156 offsetof(ngx_http_proxy_loc_conf_t, read_timeout),
|
|
157 NULL },
|
|
158
|
|
159 { ngx_string("proxy_buffers"),
|
|
160 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
|
|
161 ngx_conf_set_bufs_slot,
|
|
162 NGX_HTTP_LOC_CONF_OFFSET,
|
|
163 offsetof(ngx_http_proxy_loc_conf_t, bufs),
|
|
164 NULL },
|
|
165
|
|
166 { ngx_string("proxy_busy_buffers_size"),
|
|
167 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
168 ngx_conf_set_size_slot,
|
|
169 NGX_HTTP_LOC_CONF_OFFSET,
|
|
170 offsetof(ngx_http_proxy_loc_conf_t, busy_buffers_size),
|
|
171 NULL },
|
|
172
|
26
|
173 #if 0
|
0
|
174
|
|
175 { ngx_string("proxy_cache_path"),
|
|
176 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
|
|
177 ngx_conf_set_path_slot,
|
|
178 NGX_HTTP_LOC_CONF_OFFSET,
|
|
179 offsetof(ngx_http_proxy_loc_conf_t, cache_path),
|
26
|
180 (void *) ngx_http_cache_cleaner_handler },
|
0
|
181
|
|
182 #endif
|
|
183
|
|
184 { ngx_string("proxy_temp_path"),
|
|
185 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
|
|
186 ngx_conf_set_path_slot,
|
|
187 NGX_HTTP_LOC_CONF_OFFSET,
|
|
188 offsetof(ngx_http_proxy_loc_conf_t, temp_path),
|
|
189 (void *) ngx_garbage_collector_temp_handler },
|
|
190
|
16
|
191 { ngx_string("proxy_max_temp_file_size"),
|
|
192 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
193 ngx_conf_set_size_slot,
|
|
194 NGX_HTTP_LOC_CONF_OFFSET,
|
|
195 offsetof(ngx_http_proxy_loc_conf_t, max_temp_file_size),
|
|
196 NULL },
|
|
197
|
0
|
198 { ngx_string("proxy_temp_file_write_size"),
|
|
199 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
200 ngx_conf_set_size_slot,
|
|
201 NGX_HTTP_LOC_CONF_OFFSET,
|
|
202 offsetof(ngx_http_proxy_loc_conf_t, temp_file_write_size),
|
|
203 NULL },
|
|
204
|
|
205 { ngx_string("proxy_cache"),
|
|
206 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
207 ngx_conf_set_flag_slot,
|
|
208 NGX_HTTP_LOC_CONF_OFFSET,
|
|
209 offsetof(ngx_http_proxy_loc_conf_t, cache),
|
|
210 NULL },
|
|
211
|
|
212
|
|
213 { ngx_string("proxy_busy_lock"),
|
|
214 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE13,
|
|
215 ngx_http_set_busy_lock_slot,
|
|
216 NGX_HTTP_LOC_CONF_OFFSET,
|
|
217 offsetof(ngx_http_proxy_loc_conf_t, busy_lock),
|
|
218 NULL },
|
|
219
|
|
220
|
|
221 { ngx_string("proxy_pass_server"),
|
|
222 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
223 ngx_conf_set_flag_slot,
|
|
224 NGX_HTTP_LOC_CONF_OFFSET,
|
|
225 offsetof(ngx_http_proxy_loc_conf_t, pass_server),
|
|
226 NULL },
|
|
227
|
|
228 { ngx_string("proxy_pass_x_accel_expires"),
|
|
229 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
230 ngx_conf_set_flag_slot,
|
|
231 NGX_HTTP_LOC_CONF_OFFSET,
|
|
232 offsetof(ngx_http_proxy_loc_conf_t, pass_x_accel_expires),
|
|
233 NULL },
|
|
234
|
|
235 { ngx_string("proxy_ignore_expires"),
|
|
236 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
237 ngx_conf_set_flag_slot,
|
|
238 NGX_HTTP_LOC_CONF_OFFSET,
|
|
239 offsetof(ngx_http_proxy_loc_conf_t, ignore_expires),
|
|
240 NULL },
|
|
241
|
|
242 { ngx_string("proxy_lm_factor"),
|
|
243 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
244 ngx_conf_set_num_slot,
|
|
245 NGX_HTTP_LOC_CONF_OFFSET,
|
|
246 offsetof(ngx_http_proxy_loc_conf_t, lm_factor),
|
|
247 &ngx_http_proxy_lm_factor_bounds },
|
|
248
|
|
249 { ngx_string("proxy_default_expires"),
|
|
250 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
251 ngx_conf_set_sec_slot,
|
|
252 NGX_HTTP_LOC_CONF_OFFSET,
|
|
253 offsetof(ngx_http_proxy_loc_conf_t, default_expires),
|
|
254 NULL },
|
|
255
|
|
256 { ngx_string("proxy_next_upstream"),
|
|
257 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_ANY,
|
|
258 ngx_conf_set_bitmask_slot,
|
|
259 NGX_HTTP_LOC_CONF_OFFSET,
|
|
260 offsetof(ngx_http_proxy_loc_conf_t, next_upstream),
|
|
261 &next_upstream_masks },
|
|
262
|
|
263 { ngx_string("proxy_use_stale"),
|
|
264 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_ANY,
|
|
265 ngx_conf_set_bitmask_slot,
|
|
266 NGX_HTTP_LOC_CONF_OFFSET,
|
|
267 offsetof(ngx_http_proxy_loc_conf_t, use_stale),
|
|
268 &use_stale_masks },
|
|
269
|
|
270 ngx_null_command
|
|
271 };
|
|
272
|
|
273
|
|
274 ngx_http_module_t ngx_http_proxy_module_ctx = {
|
28
|
275 ngx_http_proxy_add_log_formats, /* pre conf */
|
0
|
276
|
|
277 NULL, /* create main configuration */
|
|
278 NULL, /* init main configuration */
|
|
279
|
|
280 NULL, /* create server configuration */
|
|
281 NULL, /* merge server configuration */
|
|
282
|
|
283 ngx_http_proxy_create_loc_conf, /* create location configration */
|
|
284 ngx_http_proxy_merge_loc_conf /* merge location configration */
|
|
285 };
|
|
286
|
|
287
|
|
288 ngx_module_t ngx_http_proxy_module = {
|
|
289 NGX_MODULE,
|
|
290 &ngx_http_proxy_module_ctx, /* module context */
|
|
291 ngx_http_proxy_commands, /* module directives */
|
|
292 NGX_HTTP_MODULE, /* module type */
|
|
293 NULL, /* init module */
|
28
|
294 NULL /* init process */
|
0
|
295 };
|
|
296
|
|
297
|
|
298
|
|
299 static ngx_http_log_op_name_t ngx_http_proxy_log_fmt_ops[] = {
|
28
|
300 { ngx_string("proxy"), 0, NULL,
|
|
301 ngx_http_proxy_log_proxy_state_getlen,
|
|
302 ngx_http_proxy_log_proxy_state },
|
|
303
|
|
304 #if 0
|
22
|
305 { ngx_string("proxy_cache_state"), 0, ngx_http_proxy_log_cache_state },
|
|
306 { ngx_string("proxy_reason"), 0, ngx_http_proxy_log_reason },
|
28
|
307 #endif
|
|
308
|
|
309 { ngx_null_string, 0, NULL, NULL, NULL }
|
0
|
310 };
|
|
311
|
|
312
|
|
313
|
|
314 ngx_http_header_t ngx_http_proxy_headers_in[] = {
|
|
315 { ngx_string("Date"), offsetof(ngx_http_proxy_headers_in_t, date) },
|
|
316 { ngx_string("Server"), offsetof(ngx_http_proxy_headers_in_t, server) },
|
|
317
|
|
318 { ngx_string("Expires"), offsetof(ngx_http_proxy_headers_in_t, expires) },
|
|
319 { ngx_string("Cache-Control"),
|
|
320 offsetof(ngx_http_proxy_headers_in_t, cache_control) },
|
|
321 { ngx_string("ETag"), offsetof(ngx_http_proxy_headers_in_t, etag) },
|
|
322 { ngx_string("X-Accel-Expires"),
|
|
323 offsetof(ngx_http_proxy_headers_in_t, x_accel_expires) },
|
|
324
|
|
325 { ngx_string("Connection"),
|
|
326 offsetof(ngx_http_proxy_headers_in_t, connection) },
|
|
327 { ngx_string("Content-Type"),
|
|
328 offsetof(ngx_http_proxy_headers_in_t, content_type) },
|
|
329 { ngx_string("Content-Length"),
|
|
330 offsetof(ngx_http_proxy_headers_in_t, content_length) },
|
28
|
331
|
|
332 #if (NGX_HTTP_GZIP)
|
4
|
333 { ngx_string("Content-Encoding"),
|
|
334 offsetof(ngx_http_proxy_headers_in_t, content_encoding) },
|
28
|
335 #endif
|
|
336
|
0
|
337 { ngx_string("Last-Modified"),
|
|
338 offsetof(ngx_http_proxy_headers_in_t, last_modified) },
|
|
339 { ngx_string("Location"),
|
|
340 offsetof(ngx_http_proxy_headers_in_t, location) },
|
|
341 { ngx_string("Accept-Ranges"),
|
|
342 offsetof(ngx_http_proxy_headers_in_t, accept_ranges) },
|
|
343 { ngx_string("X-Pad"), offsetof(ngx_http_proxy_headers_in_t, x_pad) },
|
|
344
|
|
345 { ngx_null_string, 0 }
|
|
346 };
|
|
347
|
|
348
|
|
349 static ngx_str_t cache_states[] = {
|
|
350 ngx_string("PASS"),
|
|
351 ngx_string("BYPASS"),
|
|
352 ngx_string("AUTH"),
|
|
353 ngx_string("PGNC"),
|
|
354 ngx_string("MISS"),
|
|
355 ngx_string("EXPR"),
|
|
356 ngx_string("AGED"),
|
|
357 ngx_string("HIT")
|
|
358 };
|
|
359
|
|
360
|
|
361 static ngx_str_t cache_reasons[] = {
|
|
362 ngx_string("BPS"),
|
|
363 ngx_string("XAE"),
|
|
364 ngx_string("CTL"),
|
|
365 ngx_string("EXP"),
|
|
366 ngx_string("MVD"),
|
|
367 ngx_string("LMF"),
|
|
368 ngx_string("PDE")
|
|
369 };
|
|
370
|
|
371
|
52
|
372 #if (NGX_PCRE)
|
50
|
373 static ngx_str_t ngx_http_proxy_uri = ngx_string("/");
|
52
|
374 #endif
|
50
|
375
|
|
376
|
0
|
377 static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r)
|
|
378 {
|
|
379 ngx_http_proxy_ctx_t *p;
|
|
380
|
50
|
381 p = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t));
|
|
382 if (p == NULL) {
|
|
383 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
384 }
|
|
385
|
|
386 ngx_http_set_ctx(r, p, ngx_http_proxy_module);
|
|
387
|
0
|
388
|
|
389 p->lcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
|
|
390 p->request = r;
|
|
391
|
|
392 /* TODO: we currently support reverse proxy only */
|
|
393 p->accel = 1;
|
|
394
|
26
|
395 if (ngx_array_init(&p->states, r->pool, p->lcf->peers->number,
|
|
396 sizeof(ngx_http_proxy_state_t)) == NGX_ERROR)
|
|
397 {
|
|
398 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
399 }
|
0
|
400
|
50
|
401 p->state = ngx_array_push(&p->states);
|
|
402 if (p->state == NULL) {
|
0
|
403 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
404 }
|
|
405
|
|
406 ngx_memzero(p->state, sizeof(ngx_http_proxy_state_t));
|
|
407
|
26
|
408 #if 0
|
0
|
409
|
|
410 if (!p->lcf->cache
|
|
411 || (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD))
|
|
412 {
|
|
413 p->state->cache_state = NGX_HTTP_PROXY_CACHE_PASS;
|
|
414
|
|
415 } else if (r->bypass_cache) {
|
|
416 p->state->cache_state = NGX_HTTP_PROXY_CACHE_BYPASS;
|
|
417
|
|
418 } else if (r->headers_in.authorization) {
|
|
419 p->state->cache_state = NGX_HTTP_PROXY_CACHE_AUTH;
|
|
420
|
|
421 } else if (r->no_cache) {
|
|
422 p->state->cache_state = NGX_HTTP_PROXY_CACHE_PGNC;
|
|
423 p->cachable = 1;
|
|
424
|
|
425 } else {
|
|
426 p->cachable = 1;
|
|
427 }
|
|
428
|
|
429
|
|
430 if (p->state->cache_state != 0) {
|
|
431 return ngx_http_proxy_request_upstream(p);
|
|
432 }
|
|
433
|
26
|
434 return ngx_http_proxy_cache_get(p);
|
0
|
435
|
|
436 #else
|
|
437
|
|
438 p->state->cache_state = NGX_HTTP_PROXY_CACHE_PASS;
|
|
439
|
|
440 return ngx_http_proxy_request_upstream(p);
|
|
441
|
|
442 #endif
|
|
443 }
|
|
444
|
|
445
|
26
|
446 #if 0
|
|
447
|
|
448 static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p)
|
|
449 {
|
|
450 u_char *last;
|
|
451 ngx_http_request_t *r;
|
|
452 ngx_http_cache_ctx_t ctx;
|
|
453 ngx_http_proxy_upstream_conf_t *u;
|
|
454
|
|
455 r = p->request;
|
|
456 u = p->lcf->upstream;
|
|
457
|
|
458 ctx.key.len = u->url.len + r->uri.len - u->location->len + r->args.len;
|
50
|
459 ctx.key.data = ngx_palloc(r->pool, ctx.key.len);
|
|
460 if (ctx.key.data == NULL) {
|
26
|
461 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
462 }
|
|
463
|
|
464 last = ngx_cpymem(ctx.key.data, u->url.data, u->url.len);
|
|
465
|
|
466 last = ngx_cpymem(last, r->uri.data + u->location->len,
|
|
467 r->uri.len - u->location->len);
|
|
468
|
|
469 if (r->args.len > 0) {
|
|
470 *(last++) = '?';
|
|
471 last = ngx_cpymem(last, r->args.data, r->args.len);
|
|
472 }
|
|
473
|
|
474 p->header_in = ngx_create_temp_buf(r->pool, p->lcf->header_buffer_size);
|
|
475 if (p->header_in == NULL) {
|
|
476 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
477 }
|
|
478 p->header_in->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
|
|
479
|
|
480 ctx.buf = p->header_in;
|
|
481 ctx.path = p->lcf->cache_path;
|
|
482 ctx.file = 1;
|
|
483 ctx.primary = 1;
|
|
484
|
|
485 ngx_http_cache_get(r, &ctx);
|
|
486
|
|
487 return ngx_http_proxy_request_upstream(p);
|
|
488 }
|
|
489
|
|
490 #endif
|
|
491
|
|
492
|
0
|
493 void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
|
|
494 {
|
|
495 int n;
|
|
496 char buf[1];
|
|
497 ngx_err_t err;
|
|
498 ngx_connection_t *c;
|
|
499 ngx_http_request_t *r;
|
|
500 ngx_http_proxy_ctx_t *p;
|
|
501
|
|
502 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
|
503 "http proxy check client, write event:%d", ev->write);
|
|
504
|
18
|
505 #if (NGX_HAVE_KQUEUE)
|
0
|
506
|
4
|
507 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
|
0
|
508
|
|
509 if (!ev->pending_eof) {
|
|
510 return;
|
|
511 }
|
|
512
|
|
513 c = ev->data;
|
|
514 r = c->data;
|
|
515 p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
|
516
|
|
517 ev->eof = 1;
|
|
518
|
|
519 if (ev->kq_errno) {
|
|
520 ev->error = 1;
|
|
521 }
|
|
522
|
|
523 if (!p->cachable && p->upstream->peer.connection) {
|
|
524 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno,
|
|
525 "kevent() reported that client closed "
|
|
526 "prematurely connection, "
|
|
527 "so upstream connection is closed too");
|
|
528 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
|
529 return;
|
|
530 }
|
|
531
|
|
532 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno,
|
|
533 "kevent() reported that client closed "
|
|
534 "prematurely connection");
|
|
535
|
|
536 if (p->upstream == NULL || p->upstream->peer.connection == NULL) {
|
|
537 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
|
538 }
|
|
539
|
|
540 return;
|
|
541 }
|
|
542
|
|
543 #endif
|
|
544
|
|
545 c = ev->data;
|
|
546 r = c->data;
|
|
547 p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
|
548
|
|
549 n = recv(c->fd, buf, 1, MSG_PEEK);
|
|
550
|
|
551 err = ngx_socket_errno;
|
|
552
|
|
553 /*
|
|
554 * we do not need to disable the write event because
|
|
555 * that event has NGX_USE_CLEAR_EVENT type
|
|
556 */
|
|
557
|
|
558 if (ev->write && (n >= 0 || err == NGX_EAGAIN)) {
|
|
559 return;
|
|
560 }
|
|
561
|
|
562 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) {
|
|
563 if (ngx_del_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
|
|
564 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
565 }
|
|
566 }
|
|
567
|
|
568 if (n > 0) {
|
|
569 return;
|
|
570 }
|
|
571
|
|
572 ev->eof = 1;
|
|
573
|
|
574 if (n == -1) {
|
|
575 if (err == NGX_EAGAIN) {
|
|
576 return;
|
|
577 }
|
|
578
|
|
579 ev->error = 1;
|
|
580
|
|
581 } else {
|
|
582 /* n == 0 */
|
|
583 err = 0;
|
|
584 }
|
|
585
|
|
586 if (!p->cachable && p->upstream->peer.connection) {
|
|
587 ngx_log_error(NGX_LOG_INFO, ev->log, err,
|
|
588 "client closed prematurely connection, "
|
|
589 "so upstream connection is closed too");
|
|
590 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
|
591 return;
|
|
592 }
|
|
593
|
|
594 ngx_log_error(NGX_LOG_INFO, ev->log, err,
|
|
595 "client closed prematurely connection");
|
|
596
|
|
597 if (p->upstream == NULL || p->upstream->peer.connection == NULL) {
|
|
598 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
|
599 }
|
|
600 }
|
|
601
|
|
602
|
|
603 void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev)
|
|
604 {
|
|
605 ngx_connection_t *c;
|
|
606 ngx_http_request_t *r;
|
|
607 ngx_http_proxy_ctx_t *p;
|
|
608
|
|
609 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http proxy busy lock");
|
|
610
|
|
611 c = rev->data;
|
|
612 r = c->data;
|
|
613 p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
|
614 p->action = "waiting upstream in busy lock";
|
|
615
|
|
616 if (p->request->connection->write->eof) {
|
|
617 ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
|
|
618 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
|
619 return;
|
|
620 }
|
|
621
|
|
622 if (rev->timedout) {
|
|
623 rev->timedout = 0;
|
|
624 p->busy_lock.time++;
|
|
625 p->state->bl_time = p->busy_lock.time;
|
|
626
|
|
627 #if (NGX_HTTP_FILE_CACHE)
|
|
628
|
|
629 if (p->state->cache_state < NGX_HTTP_PROXY_CACHE_MISS) {
|
|
630 ngx_http_proxy_upstream_busy_lock(p);
|
|
631
|
|
632 } else {
|
|
633 ngx_http_proxy_cache_busy_lock(p);
|
|
634 }
|
|
635 #else
|
|
636
|
|
637 ngx_http_proxy_upstream_busy_lock(p);
|
|
638
|
|
639 #endif
|
|
640
|
|
641 return;
|
|
642 }
|
|
643
|
|
644 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
|
|
645 "http proxy: client sent while busy lock");
|
|
646
|
|
647 /*
|
|
648 * TODO: kevent() notify about error, otherwise we need to
|
|
649 * call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio.
|
|
650 * if there's no error we need to disable event.
|
|
651 */
|
|
652
|
|
653 #if 0
|
18
|
654 #if (NGX_HAVE_KQUEUE)
|
0
|
655
|
18
|
656 if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && rev->kq_eof) {
|
0
|
657 ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
|
|
658
|
|
659 ngx_del_timer(rev);
|
|
660
|
|
661 ngx_log_error(NGX_LOG_ERR, c->log, rev->kq_errno,
|
|
662 "client() closed connection");
|
|
663
|
|
664 if (ngx_del_event(rev, NGX_READ_EVENT, NGX_CLOSE_EVENT) == NGX_ERROR) {
|
|
665 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
666 return;
|
|
667 }
|
|
668
|
|
669 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
|
670 return;
|
|
671 }
|
|
672
|
|
673 #endif
|
|
674 #endif
|
|
675
|
|
676 }
|
|
677
|
|
678
|
|
679 void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc)
|
|
680 {
|
|
681 ngx_http_request_t *r;
|
|
682
|
|
683 r = p->request;
|
|
684
|
|
685 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
686 "finalize http proxy request");
|
|
687
|
|
688 if (p->upstream && p->upstream->peer.connection) {
|
|
689 ngx_http_proxy_close_connection(p);
|
|
690 }
|
|
691
|
|
692 if (p->header_sent
|
|
693 && (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE))
|
|
694 {
|
|
695 rc = 0;
|
|
696 }
|
|
697
|
|
698 if (p->saved_ctx) {
|
|
699 r->connection->log->data = p->saved_ctx;
|
|
700 r->connection->log->handler = p->saved_handler;
|
|
701 }
|
|
702
|
|
703 if (p->upstream && p->upstream->event_pipe) {
|
|
704 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
705 "http proxy temp fd: %d",
|
|
706 p->upstream->event_pipe->temp_file->file.fd);
|
|
707 }
|
|
708
|
|
709 if (p->cache) {
|
|
710 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
711 "http proxy cache fd: %d",
|
|
712 p->cache->ctx.file.fd);
|
|
713 }
|
|
714
|
|
715 if (p->upstream && p->upstream->event_pipe) {
|
|
716 r->file.fd = p->upstream->event_pipe->temp_file->file.fd;
|
|
717
|
|
718 } else if (p->cache) {
|
|
719 r->file.fd = p->cache->ctx.file.fd;
|
|
720 }
|
|
721
|
|
722 if (rc == 0 && r->main == NULL) {
|
|
723 rc = ngx_http_send_last(r);
|
|
724 }
|
|
725
|
|
726 ngx_http_finalize_request(r, rc);
|
|
727 }
|
|
728
|
|
729
|
|
730 void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p)
|
|
731 {
|
|
732 ngx_socket_t fd;
|
|
733 ngx_connection_t *c;
|
|
734
|
|
735 c = p->upstream->peer.connection;
|
|
736 p->upstream->peer.connection = NULL;
|
|
737
|
|
738 if (p->lcf->busy_lock) {
|
|
739 p->lcf->busy_lock->busy--;
|
|
740 }
|
|
741
|
|
742 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
|
743 "http proxy close connection: %d", c->fd);
|
|
744
|
|
745 if (c->fd == -1) {
|
|
746 #if 0
|
|
747 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
|
|
748 #endif
|
|
749 return;
|
|
750 }
|
|
751
|
|
752 if (c->read->timer_set) {
|
|
753 ngx_del_timer(c->read);
|
|
754 }
|
|
755
|
|
756 if (c->write->timer_set) {
|
|
757 ngx_del_timer(c->write);
|
|
758 }
|
|
759
|
|
760 /* TODO: move connection to the connection pool */
|
|
761
|
|
762 if (ngx_del_conn) {
|
|
763 ngx_del_conn(c, NGX_CLOSE_EVENT);
|
|
764
|
|
765 } else {
|
|
766 if (c->read->active || c->read->disabled) {
|
|
767 ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
|
|
768 }
|
|
769
|
|
770 if (c->write->active || c->read->disabled) {
|
|
771 ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
|
|
772 }
|
|
773 }
|
|
774
|
|
775 /*
|
|
776 * we have to clean the connection information before the closing
|
|
777 * because another thread may reopen the same file descriptor
|
|
778 * before we clean the connection
|
|
779 */
|
|
780
|
|
781 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) {
|
|
782
|
|
783 if (c->read->prev) {
|
|
784 ngx_delete_posted_event(c->read);
|
|
785 }
|
|
786
|
|
787 if (c->write->prev) {
|
|
788 ngx_delete_posted_event(c->write);
|
|
789 }
|
|
790
|
|
791 c->read->closed = 1;
|
|
792 c->write->closed = 1;
|
|
793
|
|
794 ngx_mutex_unlock(ngx_posted_events_mutex);
|
|
795 }
|
|
796
|
|
797 fd = c->fd;
|
|
798 c->fd = (ngx_socket_t) -1;
|
|
799 c->data = NULL;
|
|
800
|
|
801 if (ngx_close_socket(fd) == -1) {
|
|
802 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno,
|
|
803 ngx_close_socket_n " failed");
|
|
804 }
|
|
805 }
|
|
806
|
|
807
|
32
|
808 u_char *ngx_http_proxy_log_error(ngx_log_t *log, u_char *buf, size_t len)
|
0
|
809 {
|
10
|
810 u_char *p;
|
|
811 ngx_int_t escape;
|
|
812 ngx_http_request_t *r;
|
|
813 ngx_peer_connection_t *peer;
|
32
|
814 ngx_http_proxy_log_ctx_t *ctx;
|
10
|
815 ngx_http_proxy_upstream_conf_t *uc;
|
0
|
816
|
32
|
817 ctx = log->data;
|
0
|
818 r = ctx->proxy->request;
|
10
|
819 uc = ctx->proxy->lcf->upstream;
|
0
|
820 peer = &ctx->proxy->upstream->peer;
|
|
821
|
10
|
822 p = ngx_snprintf(buf, len,
|
54
|
823 " while %s, client: %V, server: %V, URL: \"%V\","
|
52
|
824 " upstream: http://%V%s%V",
|
10
|
825 ctx->proxy->action,
|
|
826 &r->connection->addr_text,
|
52
|
827 &r->server_name,
|
10
|
828 &r->unparsed_uri,
|
28
|
829 &peer->peers->peer[peer->cur_peer].name,
|
|
830 ctx->proxy->lcf->upstream->uri_separator,
|
10
|
831 &ctx->proxy->lcf->upstream->uri);
|
|
832 len -= p - buf;
|
|
833 buf = p;
|
|
834
|
54
|
835 if (ctx->proxy->lcf->pass_unparsed_uri && r->valid_unparsed_uri) {
|
|
836 p = ngx_cpymem(buf, r->unparsed_uri.data + 1, r->unparsed_uri.len - 1);
|
|
837 len -= p - buf;
|
|
838
|
|
839 return ngx_http_log_error_info(r, p, len);
|
|
840 }
|
|
841
|
10
|
842 if (r->quoted_uri) {
|
|
843 escape = 2 * ngx_escape_uri(NULL, r->uri.data + uc->location->len,
|
|
844 r->uri.len - uc->location->len,
|
|
845 NGX_ESCAPE_URI);
|
|
846 } else {
|
|
847 escape = 0;
|
|
848 }
|
|
849
|
|
850 if (escape) {
|
|
851 if (len >= r->uri.len - uc->location->len + escape) {
|
|
852
|
|
853 ngx_escape_uri(buf, r->uri.data + uc->location->len,
|
|
854 r->uri.len - uc->location->len, NGX_ESCAPE_URI);
|
|
855
|
|
856 buf += r->uri.len - uc->location->len + escape;
|
54
|
857 len -= r->uri.len - uc->location->len + escape;
|
10
|
858
|
54
|
859 if (r->args.len) {
|
|
860 p = ngx_snprintf(buf, len, "?%V", &r->args);
|
|
861 len -= p - buf;
|
|
862 buf = p;
|
10
|
863 }
|
|
864
|
54
|
865 return ngx_http_log_error_info(r, buf, len);
|
10
|
866 }
|
|
867
|
|
868 p = ngx_palloc(r->pool, r->uri.len - uc->location->len + escape);
|
|
869 if (p == NULL) {
|
|
870 return buf;
|
|
871 }
|
|
872
|
|
873 ngx_escape_uri(p, r->uri.data + uc->location->len,
|
|
874 r->uri.len - uc->location->len, NGX_ESCAPE_URI);
|
|
875
|
54
|
876 p = ngx_cpymem(buf, p, r->uri.len - uc->location->len + escape);
|
10
|
877
|
|
878 } else {
|
54
|
879 p = ngx_cpymem(buf, r->uri.data + uc->location->len,
|
|
880 r->uri.len - uc->location->len);
|
10
|
881 }
|
|
882
|
54
|
883 len -= p - buf;
|
|
884 buf = p;
|
|
885
|
|
886 if (r->args.len) {
|
|
887 p = ngx_snprintf(buf, len, "?%V", &r->args);
|
|
888 len -= p - buf;
|
|
889 buf = p;
|
|
890 }
|
|
891
|
|
892 return ngx_http_log_error_info(r, buf, len);
|
0
|
893 }
|
|
894
|
|
895
|
28
|
896 static size_t ngx_http_proxy_log_proxy_state_getlen(ngx_http_request_t *r,
|
|
897 uintptr_t data)
|
|
898 {
|
|
899 ngx_http_proxy_ctx_t *p;
|
|
900
|
|
901 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module);
|
|
902
|
|
903 if (p == NULL) {
|
|
904 return 1;
|
|
905 }
|
|
906
|
|
907 return p->states.nelts * /* STUB */ 100;
|
|
908 }
|
|
909
|
|
910
|
0
|
911 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r,
|
28
|
912 u_char *buf,
|
|
913 ngx_http_log_op_t *op)
|
0
|
914 {
|
22
|
915 ngx_uint_t i;
|
|
916 ngx_http_proxy_ctx_t *p;
|
|
917 ngx_http_proxy_state_t *state;
|
0
|
918
|
|
919 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module);
|
|
920
|
|
921 if (p == NULL) {
|
|
922 *buf = '-';
|
|
923 return buf + 1;
|
|
924 }
|
|
925
|
22
|
926 i = 0;
|
|
927 state = p->states.elts;
|
0
|
928
|
22
|
929 for ( ;; ) {
|
|
930 if (state[i].cache_state == 0) {
|
|
931 *buf++ = '-';
|
0
|
932
|
22
|
933 } else {
|
|
934 buf = ngx_cpymem(buf, cache_states[state[i].cache_state - 1].data,
|
|
935 cache_states[state[i].cache_state - 1].len);
|
|
936 }
|
0
|
937
|
22
|
938 *buf++ = '/';
|
|
939
|
|
940 if (state[i].expired == 0) {
|
|
941 *buf++ = '-';
|
0
|
942
|
22
|
943 } else {
|
|
944 buf = ngx_sprintf(buf, "%T", state[i].expired);
|
|
945 }
|
|
946
|
|
947 *buf++ = '/';
|
|
948
|
|
949 if (state[i].bl_time == 0) {
|
|
950 *buf++ = '-';
|
0
|
951
|
22
|
952 } else {
|
|
953 buf = ngx_sprintf(buf, "%T", state[i].bl_time);
|
|
954 }
|
0
|
955
|
22
|
956 *buf++ = '/';
|
|
957
|
|
958 *buf++ = '*';
|
|
959
|
|
960 *buf++ = ' ';
|
0
|
961
|
22
|
962 if (state[i].status == 0) {
|
|
963 *buf++ = '-';
|
|
964
|
|
965 } else {
|
|
966 buf = ngx_sprintf(buf, "%ui", state[i].status);
|
|
967 }
|
0
|
968
|
22
|
969 *buf++ = '/';
|
|
970
|
|
971 if (state[i].reason == 0) {
|
|
972 *buf++ = '-';
|
|
973
|
|
974 } else {
|
|
975 buf = ngx_cpymem(buf, cache_reasons[state[i].reason - 1].data,
|
|
976 cache_reasons[state[i].reason - 1].len);
|
|
977 }
|
0
|
978
|
22
|
979 *buf++ = '/';
|
|
980
|
|
981 if (state[i].reason < NGX_HTTP_PROXY_CACHE_XAE) {
|
|
982 *buf++ = '-';
|
|
983
|
|
984 } else {
|
|
985 buf = ngx_sprintf(buf, "%T", state[i].expires);
|
|
986 }
|
0
|
987
|
22
|
988 *buf++ = ' ';
|
|
989 *buf++ = '*';
|
|
990
|
|
991 if (++i == p->states.nelts) {
|
|
992 return buf;
|
|
993 }
|
|
994
|
|
995 *buf++ = ',';
|
|
996 *buf++ = ' ';
|
0
|
997 }
|
|
998 }
|
|
999
|
|
1000
|
28
|
1001 #if 0
|
|
1002
|
0
|
1003 static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r,
|
|
1004 u_char *buf, uintptr_t data)
|
|
1005 {
|
22
|
1006 ngx_uint_t i;
|
|
1007 ngx_http_proxy_ctx_t *p;
|
|
1008 ngx_http_proxy_state_t *state;
|
0
|
1009
|
|
1010 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module);
|
|
1011
|
|
1012 if (p == NULL || p->state->cache_state == 0) {
|
22
|
1013 if (buf == NULL) {
|
|
1014 return (u_char *) 1;
|
|
1015 }
|
|
1016
|
0
|
1017 *buf = '-';
|
|
1018 return buf + 1;
|
|
1019 }
|
|
1020
|
22
|
1021 if (buf == NULL) {
|
|
1022 /* find the request line length */
|
|
1023 return (u_char *) (p->states.nelts * sizeof("BYPASS") - 1);
|
|
1024 }
|
|
1025
|
|
1026 i = 0;
|
|
1027 state = p->states.elts;
|
|
1028
|
|
1029 for ( ;; ) {
|
|
1030 buf = ngx_cpymem(buf, cache_states[state[i].cache_state - 1].data,
|
|
1031 cache_states[state[i].cache_state - 1].len);
|
|
1032
|
|
1033 if (++i == p->states.nelts) {
|
|
1034 return buf;
|
|
1035 }
|
|
1036
|
|
1037 *buf++ = ',';
|
|
1038 *buf++ = ' ';
|
|
1039 }
|
0
|
1040 }
|
|
1041
|
|
1042
|
|
1043 static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf,
|
|
1044 uintptr_t data)
|
|
1045 {
|
22
|
1046 ngx_uint_t i;
|
|
1047 ngx_http_proxy_ctx_t *p;
|
|
1048 ngx_http_proxy_state_t *state;
|
0
|
1049
|
|
1050 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module);
|
|
1051
|
|
1052 if (p == NULL || p->state->reason == 0) {
|
22
|
1053 if (buf == NULL) {
|
|
1054 return (u_char *) 1;
|
|
1055 }
|
|
1056
|
0
|
1057 *buf = '-';
|
|
1058 return buf + 1;
|
|
1059 }
|
|
1060
|
22
|
1061 if (buf == NULL) {
|
|
1062 /* find the request line length */
|
|
1063 return (u_char *) (p->states.nelts * sizeof("BPS") - 1);
|
|
1064 }
|
|
1065
|
|
1066 i = 0;
|
|
1067 state = p->states.elts;
|
|
1068
|
|
1069 for ( ;; ) {
|
|
1070 buf = ngx_cpymem(buf, cache_reasons[state[i].reason - 1].data,
|
|
1071 cache_reasons[state[i].reason - 1].len);
|
|
1072
|
|
1073 if (++i == p->states.nelts) {
|
|
1074 return buf;
|
|
1075 }
|
|
1076
|
|
1077 *buf++ = ',';
|
|
1078 *buf++ = ' ';
|
|
1079 }
|
0
|
1080 }
|
|
1081
|
28
|
1082 #endif
|
0
|
1083
|
28
|
1084
|
|
1085 static ngx_int_t ngx_http_proxy_add_log_formats(ngx_conf_t *cf)
|
0
|
1086 {
|
|
1087 ngx_http_log_op_name_t *op;
|
|
1088
|
|
1089 for (op = ngx_http_proxy_log_fmt_ops; op->name.len; op++) { /* void */ }
|
28
|
1090 op->run = NULL;
|
0
|
1091
|
28
|
1092 for (op = ngx_http_log_fmt_ops; op->run; op++) {
|
0
|
1093 if (op->name.len == 0) {
|
28
|
1094 op = (ngx_http_log_op_name_t *) op->run;
|
0
|
1095 }
|
|
1096 }
|
|
1097
|
28
|
1098 op->run = (ngx_http_log_op_run_pt) ngx_http_proxy_log_fmt_ops;
|
0
|
1099
|
|
1100 return NGX_OK;
|
|
1101 }
|
|
1102
|
|
1103
|
|
1104 static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
|
|
1105 {
|
|
1106 ngx_http_proxy_loc_conf_t *conf;
|
|
1107
|
50
|
1108 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t));
|
|
1109 if (conf == NULL) {
|
34
|
1110 return NGX_CONF_ERROR;
|
|
1111 }
|
0
|
1112
|
28
|
1113 /*
|
|
1114 * set by ngx_pcalloc():
|
|
1115 *
|
|
1116 * conf->bufs.num = 0;
|
|
1117 * conf->path = NULL;
|
|
1118 * conf->next_upstream = 0;
|
|
1119 * conf->use_stale = 0;
|
|
1120 * conf->upstreams = NULL;
|
|
1121 * conf->peers = NULL;
|
|
1122 * conf->cache_path = NULL;
|
|
1123 * conf->temp_path = NULL;
|
34
|
1124 * conf->x_vars;
|
28
|
1125 * conf->busy_lock = NULL;
|
|
1126 */
|
0
|
1127
|
|
1128 conf->connect_timeout = NGX_CONF_UNSET_MSEC;
|
|
1129 conf->send_timeout = NGX_CONF_UNSET_MSEC;
|
2
|
1130 conf->send_lowat = NGX_CONF_UNSET_SIZE;
|
0
|
1131
|
54
|
1132 conf->pass_unparsed_uri = NGX_CONF_UNSET;
|
0
|
1133 conf->preserve_host = NGX_CONF_UNSET;
|
6
|
1134 conf->set_x_url = NGX_CONF_UNSET;
|
0
|
1135 conf->set_x_real_ip = NGX_CONF_UNSET;
|
|
1136 conf->add_x_forwarded_for = NGX_CONF_UNSET;
|
|
1137
|
|
1138 conf->header_buffer_size = NGX_CONF_UNSET_SIZE;
|
|
1139 conf->read_timeout = NGX_CONF_UNSET_MSEC;
|
|
1140 conf->busy_buffers_size = NGX_CONF_UNSET_SIZE;
|
|
1141
|
16
|
1142 conf->max_temp_file_size = NGX_CONF_UNSET_SIZE;
|
0
|
1143 conf->temp_file_write_size = NGX_CONF_UNSET_SIZE;
|
|
1144
|
|
1145 /* "proxy_cyclic_temp_file" is disabled */
|
|
1146 conf->cyclic_temp_file = 0;
|
|
1147
|
|
1148 conf->cache = NGX_CONF_UNSET;
|
|
1149
|
|
1150 conf->pass_server = NGX_CONF_UNSET;
|
|
1151 conf->pass_x_accel_expires = NGX_CONF_UNSET;
|
|
1152 conf->ignore_expires = NGX_CONF_UNSET;
|
|
1153 conf->lm_factor = NGX_CONF_UNSET;
|
|
1154 conf->default_expires = NGX_CONF_UNSET;
|
|
1155
|
|
1156 return conf;
|
|
1157 }
|
|
1158
|
|
1159
|
|
1160 static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
|
|
1161 void *parent, void *child)
|
|
1162 {
|
|
1163 ngx_http_proxy_loc_conf_t *prev = parent;
|
|
1164 ngx_http_proxy_loc_conf_t *conf = child;
|
|
1165
|
|
1166 size_t size;
|
|
1167
|
|
1168 ngx_conf_merge_msec_value(conf->connect_timeout,
|
|
1169 prev->connect_timeout, 60000);
|
|
1170 ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 60000);
|
2
|
1171 ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0);
|
0
|
1172
|
54
|
1173 ngx_conf_merge_value(conf->pass_unparsed_uri, prev->pass_unparsed_uri, 0);
|
|
1174
|
|
1175 if (conf->pass_unparsed_uri && conf->upstream->location->len > 1) {
|
|
1176 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
1177 "\"proxy_pass_unparsed_uri\" can be set for "
|
|
1178 "location \"/\" or given by regular expression.");
|
|
1179 return NGX_CONF_ERROR;
|
|
1180 }
|
|
1181
|
0
|
1182 ngx_conf_merge_value(conf->preserve_host, prev->preserve_host, 0);
|
6
|
1183 ngx_conf_merge_value(conf->set_x_url, prev->set_x_url, 0);
|
0
|
1184 ngx_conf_merge_value(conf->set_x_real_ip, prev->set_x_real_ip, 0);
|
|
1185 ngx_conf_merge_value(conf->add_x_forwarded_for,
|
|
1186 prev->add_x_forwarded_for, 0);
|
|
1187
|
|
1188 ngx_conf_merge_msec_value(conf->read_timeout, prev->read_timeout, 60000);
|
|
1189
|
|
1190 ngx_conf_merge_size_value(conf->header_buffer_size,
|
|
1191 prev->header_buffer_size, (size_t) ngx_pagesize);
|
|
1192
|
|
1193 ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 8, ngx_pagesize);
|
|
1194
|
|
1195 if (conf->bufs.num < 2) {
|
|
1196 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1197 "there must be at least 2 \"proxy_buffers\"");
|
|
1198 return NGX_CONF_ERROR;
|
|
1199 }
|
|
1200
|
|
1201 size = conf->header_buffer_size;
|
|
1202 if (size < conf->bufs.size) {
|
|
1203 size = conf->bufs.size;
|
|
1204 }
|
|
1205
|
|
1206
|
|
1207 ngx_conf_merge_size_value(conf->busy_buffers_size,
|
|
1208 prev->busy_buffers_size, NGX_CONF_UNSET_SIZE);
|
|
1209
|
|
1210 if (conf->busy_buffers_size == NGX_CONF_UNSET_SIZE) {
|
|
1211 conf->busy_buffers_size = 2 * size;
|
|
1212
|
|
1213 } else if (conf->busy_buffers_size < size) {
|
|
1214 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1215 "\"proxy_busy_buffers_size\" must be equal or bigger than "
|
|
1216 "maximum of the value of \"proxy_header_buffer_size\" and "
|
|
1217 "one of the \"proxy_buffers\"");
|
|
1218
|
|
1219 return NGX_CONF_ERROR;
|
|
1220
|
|
1221 } else if (conf->busy_buffers_size > (conf->bufs.num - 1) * conf->bufs.size)
|
|
1222 {
|
|
1223 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1224 "\"proxy_busy_buffers_size\" must be less than "
|
|
1225 "the size of all \"proxy_buffers\" minus one buffer");
|
|
1226
|
|
1227 return NGX_CONF_ERROR;
|
|
1228 }
|
|
1229
|
|
1230
|
|
1231 ngx_conf_merge_size_value(conf->temp_file_write_size,
|
|
1232 prev->temp_file_write_size, NGX_CONF_UNSET_SIZE);
|
|
1233
|
|
1234 if (conf->temp_file_write_size == NGX_CONF_UNSET_SIZE) {
|
|
1235 conf->temp_file_write_size = 2 * size;
|
|
1236
|
|
1237 } else if (conf->temp_file_write_size < size) {
|
|
1238 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1239 "\"proxy_temp_file_write_size\" must be equal or bigger than "
|
|
1240 "maximum of the value of \"proxy_header_buffer_size\" and "
|
|
1241 "one of the \"proxy_buffers\"");
|
|
1242
|
|
1243 return NGX_CONF_ERROR;
|
|
1244 }
|
|
1245
|
|
1246
|
|
1247 ngx_conf_merge_size_value(conf->max_temp_file_size,
|
|
1248 prev->max_temp_file_size, NGX_CONF_UNSET_SIZE);
|
|
1249
|
|
1250 if (conf->max_temp_file_size == NGX_CONF_UNSET_SIZE) {
|
16
|
1251
|
|
1252 /*
|
|
1253 * "proxy_max_temp_file_size" is set to 1G for reverse proxy,
|
|
1254 * it should be much less in the generic proxy
|
|
1255 */
|
|
1256
|
|
1257 conf->max_temp_file_size = 1024 * 1024 * 1024;
|
0
|
1258
|
16
|
1259 #if 0
|
|
1260 conf->max_temp_file_size = 2 * size;
|
|
1261 #endif
|
|
1262
|
|
1263
|
|
1264 } else if (conf->max_temp_file_size != 0
|
|
1265 && conf->max_temp_file_size < size)
|
|
1266 {
|
0
|
1267 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
16
|
1268 "\"proxy_max_temp_file_size\" must be equal to zero to disable "
|
|
1269 "the temporary files usage or must be equal or bigger than "
|
0
|
1270 "maximum of the value of \"proxy_header_buffer_size\" and "
|
|
1271 "one of the \"proxy_buffers\"");
|
|
1272
|
|
1273 return NGX_CONF_ERROR;
|
|
1274 }
|
|
1275
|
|
1276
|
|
1277 ngx_conf_merge_bitmask_value(conf->next_upstream, prev->next_upstream,
|
|
1278 (NGX_CONF_BITMASK_SET
|
|
1279 |NGX_HTTP_PROXY_FT_ERROR
|
|
1280 |NGX_HTTP_PROXY_FT_TIMEOUT));
|
|
1281
|
|
1282 ngx_conf_merge_bitmask_value(conf->use_stale, prev->use_stale,
|
|
1283 NGX_CONF_BITMASK_SET);
|
|
1284
|
28
|
1285 #if 0
|
0
|
1286 ngx_conf_merge_path_value(conf->cache_path, prev->cache_path,
|
28
|
1287 NGX_HTTP_PROXY_CACHE_PATH, 1, 2, 0,
|
|
1288 ngx_garbage_collector_temp_handler, cf);
|
|
1289 #endif
|
0
|
1290
|
|
1291 ngx_conf_merge_path_value(conf->temp_path, prev->temp_path,
|
28
|
1292 NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0,
|
|
1293 ngx_garbage_collector_temp_handler, cf);
|
0
|
1294
|
|
1295 ngx_conf_merge_value(conf->cache, prev->cache, 0);
|
|
1296
|
|
1297
|
|
1298 /* conf->cache must be merged */
|
|
1299
|
|
1300 if (conf->busy_lock == NULL) {
|
|
1301 conf->busy_lock = prev->busy_lock;
|
|
1302 }
|
|
1303
|
|
1304 if (conf->busy_lock && conf->cache && conf->busy_lock->md5 == NULL) {
|
|
1305
|
|
1306 /* ngx_calloc_shared() */
|
|
1307 conf->busy_lock->md5_mask =
|
|
1308 ngx_pcalloc(cf->pool, (conf->busy_lock->max_busy + 7) / 8);
|
|
1309 if (conf->busy_lock->md5_mask == NULL) {
|
|
1310 return NGX_CONF_ERROR;
|
|
1311 }
|
|
1312
|
|
1313 /* 16 bytes are 128 bits of the md5 */
|
|
1314
|
|
1315 /* ngx_alloc_shared() */
|
|
1316 conf->busy_lock->md5 = ngx_palloc(cf->pool,
|
|
1317 16 * conf->busy_lock->max_busy);
|
|
1318 if (conf->busy_lock->md5 == NULL) {
|
|
1319 return NGX_CONF_ERROR;
|
|
1320 }
|
|
1321 }
|
|
1322
|
|
1323
|
|
1324 ngx_conf_merge_value(conf->pass_server, prev->pass_server, 0);
|
|
1325 ngx_conf_merge_value(conf->pass_x_accel_expires,
|
|
1326 prev->pass_x_accel_expires, 0);
|
|
1327 ngx_conf_merge_value(conf->ignore_expires, prev->ignore_expires, 0);
|
|
1328 ngx_conf_merge_value(conf->lm_factor, prev->lm_factor, 0);
|
|
1329 ngx_conf_merge_sec_value(conf->default_expires, prev->default_expires, 0);
|
|
1330
|
36
|
1331 if (conf->x_vars == NULL) {
|
|
1332 conf->x_vars = prev->x_vars;
|
|
1333 }
|
|
1334
|
56
|
1335 if (conf->peers == NULL) {
|
|
1336 conf->peers = prev->peers;
|
|
1337 conf->upstream = prev->upstream;
|
|
1338 }
|
|
1339
|
0
|
1340 return NULL;
|
|
1341 }
|
|
1342
|
|
1343
|
|
1344 static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
1345 void *conf)
|
|
1346 {
|
|
1347 ngx_http_proxy_loc_conf_t *lcf = conf;
|
|
1348
|
28
|
1349 ngx_str_t *value, *url;
|
|
1350 ngx_inet_upstream_t inet_upstream;
|
|
1351 ngx_http_core_loc_conf_t *clcf;
|
|
1352 #if (NGX_HAVE_UNIX_DOMAIN)
|
|
1353 ngx_unix_domain_upstream_t unix_upstream;
|
|
1354 #endif
|
0
|
1355
|
|
1356 value = cf->args->elts;
|
|
1357
|
28
|
1358 url = &value[1];
|
|
1359
|
|
1360 if (ngx_strncasecmp(url->data, "http://", 7) != 0) {
|
2
|
1361 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid URL prefix");
|
|
1362 return NGX_CONF_ERROR;
|
0
|
1363 }
|
|
1364
|
2
|
1365 lcf->upstream = ngx_pcalloc(cf->pool,
|
|
1366 sizeof(ngx_http_proxy_upstream_conf_t));
|
|
1367 if (lcf->upstream == NULL) {
|
|
1368 return NGX_CONF_ERROR;
|
|
1369 }
|
0
|
1370
|
34
|
1371 lcf->upstream->url = *url;
|
|
1372
|
28
|
1373 if (ngx_strncasecmp(url->data + 7, "unix:", 5) == 0) {
|
0
|
1374
|
28
|
1375 #if (NGX_HAVE_UNIX_DOMAIN)
|
0
|
1376
|
28
|
1377 ngx_memzero(&unix_upstream, sizeof(ngx_unix_domain_upstream_t));
|
2
|
1378
|
28
|
1379 unix_upstream.name = *url;
|
|
1380 unix_upstream.url.len = url->len - 7;
|
|
1381 unix_upstream.url.data = url->data + 7;
|
|
1382 unix_upstream.uri_part = 1;
|
0
|
1383
|
50
|
1384 lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream);
|
|
1385 if (lcf->peers == NULL) {
|
2
|
1386 return NGX_CONF_ERROR;
|
|
1387 }
|
0
|
1388
|
28
|
1389 lcf->upstream->host_header.len = sizeof("localhost") - 1;
|
|
1390 lcf->upstream->host_header.data = (u_char *) "localhost";
|
|
1391 lcf->upstream->uri = unix_upstream.uri;
|
|
1392 lcf->upstream->uri_separator = ":";
|
|
1393 lcf->upstream->default_port = 1;
|
2
|
1394
|
28
|
1395 #else
|
|
1396 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1397 "the unix domain sockets are not supported "
|
|
1398 "on this platform");
|
|
1399 return NGX_CONF_ERROR;
|
0
|
1400
|
28
|
1401 #endif
|
0
|
1402
|
|
1403 } else {
|
28
|
1404 ngx_memzero(&inet_upstream, sizeof(ngx_inet_upstream_t));
|
0
|
1405
|
28
|
1406 inet_upstream.name = *url;
|
|
1407 inet_upstream.url.len = url->len - 7;
|
|
1408 inet_upstream.url.data = url->data + 7;
|
|
1409 inet_upstream.default_port_value = 80;
|
|
1410 inet_upstream.uri_part = 1;
|
0
|
1411
|
50
|
1412 lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream);
|
|
1413 if (lcf->peers == NULL) {
|
2
|
1414 return NGX_CONF_ERROR;
|
|
1415 }
|
0
|
1416
|
28
|
1417 lcf->upstream->host_header = inet_upstream.host_header;
|
|
1418 lcf->upstream->port_text = inet_upstream.port_text;
|
|
1419 lcf->upstream->uri = inet_upstream.uri;
|
|
1420 lcf->upstream->uri_separator = "";
|
30
|
1421 lcf->upstream->default_port = inet_upstream.default_port;
|
0
|
1422 }
|
|
1423
|
|
1424 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
|
1425
|
50
|
1426 clcf->handler = ngx_http_proxy_handler;
|
|
1427
|
|
1428 #if (NGX_PCRE)
|
|
1429 lcf->upstream->location = clcf->regex ? &ngx_http_proxy_uri : &clcf->name;
|
|
1430 #else
|
0
|
1431 lcf->upstream->location = &clcf->name;
|
50
|
1432 #endif
|
0
|
1433
|
|
1434 if (clcf->name.data[clcf->name.len - 1] == '/') {
|
|
1435 clcf->auto_redirect = 1;
|
|
1436 }
|
|
1437
|
28
|
1438 return NGX_CONF_OK;
|
0
|
1439 }
|
2
|
1440
|
|
1441
|
34
|
1442 static char *ngx_http_proxy_set_x_var(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
1443 void *conf)
|
|
1444 {
|
|
1445 ngx_http_proxy_loc_conf_t *lcf = conf;
|
|
1446
|
|
1447 ngx_uint_t i, *index;
|
|
1448 ngx_str_t *value;
|
|
1449 ngx_http_variable_t *var;
|
|
1450 ngx_http_core_main_conf_t *cmcf;
|
|
1451
|
36
|
1452 if (lcf->x_vars == NULL) {
|
|
1453 lcf->x_vars = ngx_array_create(cf->pool, 4,
|
|
1454 sizeof(ngx_http_variable_t *));
|
|
1455 if (lcf->x_vars == NULL) {
|
34
|
1456 return NGX_CONF_ERROR;
|
|
1457 }
|
|
1458 }
|
|
1459
|
|
1460 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
|
1461
|
|
1462 value = cf->args->elts;
|
|
1463
|
|
1464 var = cmcf->variables.elts;
|
|
1465 for (i = 0; i < cmcf->variables.nelts; i++) {
|
|
1466 if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) {
|
|
1467
|
50
|
1468 index = ngx_array_push(lcf->x_vars);
|
|
1469 if (index == NULL) {
|
34
|
1470 return NGX_CONF_ERROR;
|
|
1471 }
|
|
1472
|
|
1473 *index = var[i].index;
|
|
1474 return NGX_CONF_OK;
|
|
1475 }
|
|
1476 }
|
|
1477
|
|
1478 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1479 "unknown variable name \"%V\"", &value[1]);
|
|
1480 return NGX_CONF_ERROR;
|
|
1481 }
|
|
1482
|
|
1483
|
2
|
1484 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data)
|
|
1485 {
|
22
|
1486 #if (NGX_FREEBSD)
|
4
|
1487 ssize_t *np = data;
|
2
|
1488
|
|
1489 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
|
|
1490 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
1491 "\"proxy_send_lowat\" must be less than %d "
|
|
1492 "(sysctl net.inet.tcp.sendspace)",
|
|
1493 ngx_freebsd_net_inet_tcp_sendspace);
|
|
1494
|
|
1495 return NGX_CONF_ERROR;
|
|
1496 }
|
|
1497
|
18
|
1498 #elif !(NGX_HAVE_SO_SNDLOWAT)
|
22
|
1499 ssize_t *np = data;
|
2
|
1500
|
|
1501 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
|
1502 "\"proxy_send_lowat\" is not supported, ignored");
|
|
1503
|
|
1504 *np = 0;
|
|
1505
|
|
1506 #endif
|
|
1507
|
|
1508 return NGX_CONF_OK;
|
|
1509 }
|