comparison src/http/modules/ngx_http_proxy_module.c @ 260:0effe91f6083 NGINX_0_5_0

nginx 0.5.0 *) Change: the parameters in the "%name" form in the "log_format" directive are not supported anymore. *) Change: the "proxy_upstream_max_fails", "proxy_upstream_fail_timeout", "fastcgi_upstream_max_fails", "fastcgi_upstream_fail_timeout", "memcached_upstream_max_fails", and "memcached_upstream_fail_timeout" directives are not supported anymore. *) Feature: the "server" directive in the "upstream" context supports the "max_fails", "fail_timeout", and "down" parameters. *) Feature: the "ip_hash" directive inside the "upstream" block. *) Feature: the WAIT status in the "Auth-Status" header line of the IMAP/POP3 proxy authentication server response. *) Bugfix: nginx could not be built on 64-bit platforms; bug appeared in 0.4.14.
author Igor Sysoev <http://sysoev.ru>
date Mon, 04 Dec 2006 00:00:00 +0300
parents 2e9c57a5e50a
children e0b1d0a6c629
comparison
equal deleted inserted replaced
259:c68f18041059 260:0effe91f6083
32 }; 32 };
33 33
34 34
35 typedef struct { 35 typedef struct {
36 ngx_http_upstream_conf_t upstream; 36 ngx_http_upstream_conf_t upstream;
37
38 ngx_http_upstream_srv_conf_t *upstream_peers;
39 37
40 ngx_array_t *flushes; 38 ngx_array_t *flushes;
41 ngx_array_t *body_set_len; 39 ngx_array_t *body_set_len;
42 ngx_array_t *body_set; 40 ngx_array_t *body_set;
43 ngx_array_t *headers_set_len; 41 ngx_array_t *headers_set_len;
105 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, 103 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd,
106 void *conf); 104 void *conf);
107 105
108 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); 106 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data);
109 107
108 static char *ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf,
109 ngx_command_t *cmd, void *conf);
110 static char *ngx_http_proxy_upstream_fail_timeout_unsupported(ngx_conf_t *cf,
111 ngx_command_t *cmd, void *conf);
112
110 113
111 static ngx_conf_post_t ngx_http_proxy_lowat_post = 114 static ngx_conf_post_t ngx_http_proxy_lowat_post =
112 { ngx_http_proxy_lowat_check }; 115 { ngx_http_proxy_lowat_check };
113 116
114 static ngx_conf_deprecated_t ngx_conf_deprecated_proxy_header_buffer_size = { 117 static ngx_conf_deprecated_t ngx_conf_deprecated_proxy_header_buffer_size = {
295 offsetof(ngx_http_proxy_loc_conf_t, upstream.next_upstream), 298 offsetof(ngx_http_proxy_loc_conf_t, upstream.next_upstream),
296 &ngx_http_proxy_next_upstream_masks }, 299 &ngx_http_proxy_next_upstream_masks },
297 300
298 { ngx_string("proxy_upstream_max_fails"), 301 { ngx_string("proxy_upstream_max_fails"),
299 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 302 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
300 ngx_conf_set_num_slot, 303 ngx_http_proxy_upstream_max_fails_unsupported,
301 NGX_HTTP_LOC_CONF_OFFSET, 304 0,
302 offsetof(ngx_http_proxy_loc_conf_t, upstream.max_fails), 305 0,
303 NULL }, 306 NULL },
304 307
305 { ngx_string("proxy_upstream_fail_timeout"), 308 { ngx_string("proxy_upstream_fail_timeout"),
306 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 309 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
307 ngx_conf_set_sec_slot, 310 ngx_http_proxy_upstream_fail_timeout_unsupported,
308 NGX_HTTP_LOC_CONF_OFFSET, 311 0,
309 offsetof(ngx_http_proxy_loc_conf_t, upstream.fail_timeout), 312 0,
310 NULL }, 313 NULL },
311 314
312 { ngx_string("proxy_pass_header"), 315 { ngx_string("proxy_pass_header"),
313 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 316 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
314 ngx_conf_set_str_array_slot, 317 ngx_conf_set_str_array_slot,
417 return NGX_HTTP_INTERNAL_SERVER_ERROR; 420 return NGX_HTTP_INTERNAL_SERVER_ERROR;
418 } 421 }
419 422
420 u->peer.log = r->connection->log; 423 u->peer.log = r->connection->log;
421 u->peer.log_error = NGX_ERROR_ERR; 424 u->peer.log_error = NGX_ERROR_ERR;
422 u->peer.peers = plcf->upstream_peers->peers;
423 u->peer.tries = plcf->upstream_peers->peers->number;
424 #if (NGX_THREADS) 425 #if (NGX_THREADS)
425 u->peer.lock = &r->connection->lock; 426 u->peer.lock = &r->connection->lock;
426 #endif 427 #endif
427 428
428 u->output.tag = (ngx_buf_tag_t) &ngx_http_proxy_module; 429 u->output.tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
1496 1497
1497 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; 1498 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
1498 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; 1499 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
1499 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; 1500 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
1500 1501
1501 conf->upstream.max_fails = NGX_CONF_UNSET_UINT;
1502 conf->upstream.fail_timeout = NGX_CONF_UNSET;
1503
1504 conf->upstream.pass_request_headers = NGX_CONF_UNSET; 1502 conf->upstream.pass_request_headers = NGX_CONF_UNSET;
1505 conf->upstream.pass_request_body = NGX_CONF_UNSET; 1503 conf->upstream.pass_request_body = NGX_CONF_UNSET;
1506 1504
1507 conf->upstream.intercept_errors = NGX_CONF_UNSET; 1505 conf->upstream.intercept_errors = NGX_CONF_UNSET;
1508 1506
1525 u_char *p; 1523 u_char *p;
1526 size_t size; 1524 size_t size;
1527 uintptr_t *code; 1525 uintptr_t *code;
1528 ngx_str_t *header; 1526 ngx_str_t *header;
1529 ngx_uint_t i, j; 1527 ngx_uint_t i, j;
1530 ngx_peer_t *peer;
1531 ngx_array_t hide_headers; 1528 ngx_array_t hide_headers;
1532 ngx_keyval_t *src, *s, *h; 1529 ngx_keyval_t *src, *s, *h;
1533 ngx_hash_key_t *hk; 1530 ngx_hash_key_t *hk;
1534 ngx_hash_init_t hash; 1531 ngx_hash_init_t hash;
1535 ngx_http_proxy_redirect_t *pr; 1532 ngx_http_proxy_redirect_t *pr;
1658 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { 1655 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
1659 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET 1656 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
1660 |NGX_HTTP_UPSTREAM_FT_OFF; 1657 |NGX_HTTP_UPSTREAM_FT_OFF;
1661 } 1658 }
1662 1659
1663 ngx_conf_merge_uint_value(conf->upstream.max_fails,
1664 prev->upstream.max_fails, 1);
1665
1666 ngx_conf_merge_sec_value(conf->upstream.fail_timeout,
1667 prev->upstream.fail_timeout, 10);
1668
1669 if (conf->upstream_peers) {
1670 peer = conf->upstream_peers->peers->peer;
1671 for (i = 0; i < conf->upstream_peers->peers->number; i++) {
1672 ngx_conf_init_uint_value(peer[i].weight, 1);
1673 peer[i].current_weight = peer[i].weight;
1674 ngx_conf_init_uint_value(peer[i].max_fails,
1675 conf->upstream.max_fails);
1676 ngx_conf_init_value(peer[i].fail_timeout,
1677 conf->upstream.fail_timeout);
1678 }
1679 }
1680
1681 ngx_conf_merge_path_value(conf->upstream.temp_path, 1660 ngx_conf_merge_path_value(conf->upstream.temp_path,
1682 prev->upstream.temp_path, 1661 prev->upstream.temp_path,
1683 NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0, 1662 NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0,
1684 ngx_garbage_collector_temp_handler, cf); 1663 ngx_garbage_collector_temp_handler, cf);
1685 1664
1832 return NGX_CONF_ERROR; 1811 return NGX_CONF_ERROR;
1833 } 1812 }
1834 1813
1835 peers: 1814 peers:
1836 1815
1837 if (conf->upstream_peers == NULL) { 1816 if (conf->upstream.upstream == NULL) {
1838 conf->upstream_peers = prev->upstream_peers; 1817 conf->upstream.upstream = prev->upstream.upstream;
1839 1818
1840 conf->host_header = prev->host_header; 1819 conf->host_header = prev->host_header;
1841 conf->port_text = prev->port_text; 1820 conf->port_text = prev->port_text;
1842 conf->upstream.schema = prev->upstream.schema; 1821 conf->upstream.schema = prev->upstream.schema;
1843 } 1822 }
2178 ngx_memzero(&u, sizeof(ngx_url_t)); 2157 ngx_memzero(&u, sizeof(ngx_url_t));
2179 2158
2180 u.url.len = url->len - add; 2159 u.url.len = url->len - add;
2181 u.url.data = url->data + add; 2160 u.url.data = url->data + add;
2182 u.default_portn = port; 2161 u.default_portn = port;
2162 u.no_resolve = 1;
2183 u.uri_part = 1; 2163 u.uri_part = 1;
2184 u.upstream = 1; 2164
2185 2165 plcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
2186 plcf->upstream_peers = ngx_http_upstream_add(cf, &u); 2166 if (plcf->upstream.upstream == NULL) {
2187 if (plcf->upstream_peers == NULL) {
2188 return NGX_CONF_ERROR; 2167 return NGX_CONF_ERROR;
2189 } 2168 }
2190 2169
2191 plcf->host_header = u.host_header; 2170 plcf->host_header = u.host_header;
2192 plcf->port_text = u.port; 2171 plcf->port_text = u.port;
2343 2322
2344 #endif 2323 #endif
2345 2324
2346 return NGX_CONF_OK; 2325 return NGX_CONF_OK;
2347 } 2326 }
2327
2328
2329 static char *
2330 ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf,
2331 ngx_command_t *cmd, void *conf)
2332 {
2333 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2334 "\"proxy_upstream_max_fails\" is not supported, "
2335 "use the \"max_fails\" parameter of the \"server\" directive ",
2336 "inside the \"upstream\" block");
2337
2338 return NGX_CONF_ERROR;
2339 }
2340
2341
2342 static char *
2343 ngx_http_proxy_upstream_fail_timeout_unsupported(ngx_conf_t *cf,
2344 ngx_command_t *cmd, void *conf)
2345 {
2346 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2347 "\"proxy_upstream_fail_timeout\" is not supported, "
2348 "use the \"fail_timeout\" parameter of the \"server\" directive ",
2349 "inside the \"upstream\" block");
2350
2351 return NGX_CONF_ERROR;
2352 }