Mercurial > hg > nginx-ranges
comparison src/http/modules/proxy/ngx_http_proxy_handler.c @ 26:45fe5b98a9de NGINX_0_1_13
nginx 0.1.13
*) Feature: the server_names_hash and server_names_hash_threshold
directives.
*) Bugfix: the *.domain.tld names in the "server_name" directive did
not work.
*) Bugfix: the %request_length log parameter logged the incorrect
length.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 21 Dec 2004 00:00:00 +0300 |
parents | 8b6db3bda591 |
children | 7ca9bdc82b3f |
comparison
equal
deleted
inserted
replaced
25:21488c53e135 | 26:45fe5b98a9de |
---|---|
9 #include <ngx_http.h> | 9 #include <ngx_http.h> |
10 #include <ngx_http_proxy_handler.h> | 10 #include <ngx_http_proxy_handler.h> |
11 | 11 |
12 | 12 |
13 static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r); | 13 static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r); |
14 static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p); | |
14 | 15 |
15 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, | 16 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, |
16 u_char *buf, uintptr_t data); | 17 u_char *buf, uintptr_t data); |
17 static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, | 18 static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, |
18 u_char *buf, uintptr_t data); | 19 u_char *buf, uintptr_t data); |
145 ngx_conf_set_size_slot, | 146 ngx_conf_set_size_slot, |
146 NGX_HTTP_LOC_CONF_OFFSET, | 147 NGX_HTTP_LOC_CONF_OFFSET, |
147 offsetof(ngx_http_proxy_loc_conf_t, busy_buffers_size), | 148 offsetof(ngx_http_proxy_loc_conf_t, busy_buffers_size), |
148 NULL }, | 149 NULL }, |
149 | 150 |
150 #if (NGX_HTTP_FILE_CACHE) | 151 #if 0 |
151 | 152 |
152 { ngx_string("proxy_cache_path"), | 153 { ngx_string("proxy_cache_path"), |
153 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | 154 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, |
154 ngx_conf_set_path_slot, | 155 ngx_conf_set_path_slot, |
155 NGX_HTTP_LOC_CONF_OFFSET, | 156 NGX_HTTP_LOC_CONF_OFFSET, |
156 offsetof(ngx_http_proxy_loc_conf_t, cache_path), | 157 offsetof(ngx_http_proxy_loc_conf_t, cache_path), |
157 ngx_garbage_collector_http_cache_handler }, | 158 (void *) ngx_http_cache_cleaner_handler }, |
158 | 159 |
159 #endif | 160 #endif |
160 | 161 |
161 { ngx_string("proxy_temp_path"), | 162 { ngx_string("proxy_temp_path"), |
162 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | 163 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, |
349 p->request = r; | 350 p->request = r; |
350 | 351 |
351 /* TODO: we currently support reverse proxy only */ | 352 /* TODO: we currently support reverse proxy only */ |
352 p->accel = 1; | 353 p->accel = 1; |
353 | 354 |
354 ngx_init_array(p->states, r->pool, p->lcf->peers->number, | 355 if (ngx_array_init(&p->states, r->pool, p->lcf->peers->number, |
355 sizeof(ngx_http_proxy_state_t), | 356 sizeof(ngx_http_proxy_state_t)) == NGX_ERROR) |
356 NGX_HTTP_INTERNAL_SERVER_ERROR); | 357 { |
357 | |
358 if (!(p->state = ngx_push_array(&p->states))) { | |
359 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 358 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
360 } | 359 } |
361 | 360 |
361 if (!(p->state = ngx_array_push(&p->states))) { | |
362 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
363 } | |
364 | |
362 ngx_memzero(p->state, sizeof(ngx_http_proxy_state_t)); | 365 ngx_memzero(p->state, sizeof(ngx_http_proxy_state_t)); |
363 | 366 |
364 #if (NGX_HTTP_FILE_CACHE) | 367 #if 0 |
365 | 368 |
366 if (!p->lcf->cache | 369 if (!p->lcf->cache |
367 || (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD)) | 370 || (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD)) |
368 { | 371 { |
369 p->state->cache_state = NGX_HTTP_PROXY_CACHE_PASS; | 372 p->state->cache_state = NGX_HTTP_PROXY_CACHE_PASS; |
385 | 388 |
386 if (p->state->cache_state != 0) { | 389 if (p->state->cache_state != 0) { |
387 return ngx_http_proxy_request_upstream(p); | 390 return ngx_http_proxy_request_upstream(p); |
388 } | 391 } |
389 | 392 |
390 return ngx_http_proxy_get_cached_response(p); | 393 return ngx_http_proxy_cache_get(p); |
391 | 394 |
392 #else | 395 #else |
393 | 396 |
394 p->state->cache_state = NGX_HTTP_PROXY_CACHE_PASS; | 397 p->state->cache_state = NGX_HTTP_PROXY_CACHE_PASS; |
395 | 398 |
396 return ngx_http_proxy_request_upstream(p); | 399 return ngx_http_proxy_request_upstream(p); |
397 | 400 |
398 #endif | 401 #endif |
399 } | 402 } |
403 | |
404 | |
405 #if 0 | |
406 | |
407 static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p) | |
408 { | |
409 u_char *last; | |
410 ngx_http_request_t *r; | |
411 ngx_http_cache_ctx_t ctx; | |
412 ngx_http_proxy_upstream_conf_t *u; | |
413 | |
414 r = p->request; | |
415 u = p->lcf->upstream; | |
416 | |
417 ctx.key.len = u->url.len + r->uri.len - u->location->len + r->args.len; | |
418 if (!(ctx.key.data = ngx_palloc(r->pool, ctx.key.len))) { | |
419 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
420 } | |
421 | |
422 last = ngx_cpymem(ctx.key.data, u->url.data, u->url.len); | |
423 | |
424 last = ngx_cpymem(last, r->uri.data + u->location->len, | |
425 r->uri.len - u->location->len); | |
426 | |
427 if (r->args.len > 0) { | |
428 *(last++) = '?'; | |
429 last = ngx_cpymem(last, r->args.data, r->args.len); | |
430 } | |
431 | |
432 p->header_in = ngx_create_temp_buf(r->pool, p->lcf->header_buffer_size); | |
433 if (p->header_in == NULL) { | |
434 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
435 } | |
436 p->header_in->tag = (ngx_buf_tag_t) &ngx_http_proxy_module; | |
437 | |
438 ctx.buf = p->header_in; | |
439 ctx.path = p->lcf->cache_path; | |
440 ctx.file = 1; | |
441 ctx.primary = 1; | |
442 | |
443 ngx_http_cache_get(r, &ctx); | |
444 | |
445 return ngx_http_proxy_request_upstream(p); | |
446 } | |
447 | |
448 #endif | |
400 | 449 |
401 | 450 |
402 void ngx_http_proxy_check_broken_connection(ngx_event_t *ev) | 451 void ngx_http_proxy_check_broken_connection(ngx_event_t *ev) |
403 { | 452 { |
404 int n; | 453 int n; |