comparison src/http/modules/ngx_http_proxy_module.c @ 320:95183808f549 NGINX_0_6_4

nginx 0.6.4 *) Security: the "msie_refresh" directive allowed XSS. Thanks to Maxim Boguk. *) Change: the "proxy_store" and "fastcgi_store" directives were changed. *) Feature: the "proxy_store_access" and "fastcgi_store_access" directives. *) Bugfix: nginx did not work on Solaris/sparc64 if it was built by Sun Studio. Thanks to Andrei Nigmatulin. *) Workaround: for Sun Studio 12. Thanks to Jiang Hong.
author Igor Sysoev <http://sysoev.ru>
date Tue, 17 Jul 2007 00:00:00 +0400
parents fc223117327f
children f7cd062ee035
comparison
equal deleted inserted replaced
319:6ccd0af7f704 320:95183808f549
103 103
104 static char *ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, 104 static char *ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd,
105 void *conf); 105 void *conf);
106 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, 106 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd,
107 void *conf); 107 void *conf);
108 static char *ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd,
109 void *conf);
108 110
109 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); 111 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data);
110 112
111 static char *ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf, 113 static char *ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf,
112 ngx_command_t *cmd, void *conf); 114 ngx_command_t *cmd, void *conf);
153 NGX_HTTP_LOC_CONF_OFFSET, 155 NGX_HTTP_LOC_CONF_OFFSET,
154 0, 156 0,
155 NULL }, 157 NULL },
156 158
157 { ngx_string("proxy_store"), 159 { ngx_string("proxy_store"),
160 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
161 ngx_http_proxy_store,
162 NGX_HTTP_LOC_CONF_OFFSET,
163 0,
164 NULL },
165
166 { ngx_string("proxy_store_access"),
158 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, 167 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
159 ngx_conf_set_access_slot, 168 ngx_conf_set_access_slot,
160 NGX_HTTP_LOC_CONF_OFFSET, 169 NGX_HTTP_LOC_CONF_OFFSET,
161 offsetof(ngx_http_proxy_loc_conf_t, upstream.store), 170 offsetof(ngx_http_proxy_loc_conf_t, upstream.store_access),
162 NULL }, 171 NULL },
163 172
164 { ngx_string("proxy_buffering"), 173 { ngx_string("proxy_buffering"),
165 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 174 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
166 ngx_conf_set_flag_slot, 175 ngx_conf_set_flag_slot,
1495 * conf->upstream.hide_headers = NULL; 1504 * conf->upstream.hide_headers = NULL;
1496 * conf->upstream.pass_headers = NULL; 1505 * conf->upstream.pass_headers = NULL;
1497 * conf->upstream.schema = { 0, NULL }; 1506 * conf->upstream.schema = { 0, NULL };
1498 * conf->upstream.uri = { 0, NULL }; 1507 * conf->upstream.uri = { 0, NULL };
1499 * conf->upstream.location = NULL; 1508 * conf->upstream.location = NULL;
1509 * conf->upstream.store_lengths = NULL;
1510 * conf->upstream.store_values = NULL;
1500 * 1511 *
1501 * conf->method = NULL; 1512 * conf->method = NULL;
1502 * conf->headers_source = NULL; 1513 * conf->headers_source = NULL;
1503 * conf->headers_set_len = NULL; 1514 * conf->headers_set_len = NULL;
1504 * conf->headers_set = NULL; 1515 * conf->headers_set = NULL;
1507 * conf->body_set = NULL; 1518 * conf->body_set = NULL;
1508 * conf->body_source = { 0, NULL }; 1519 * conf->body_source = { 0, NULL };
1509 * conf->rewrite_locations = NULL; 1520 * conf->rewrite_locations = NULL;
1510 */ 1521 */
1511 1522
1512 conf->upstream.store = NGX_CONF_UNSET_UINT; 1523 conf->upstream.store = NGX_CONF_UNSET;
1524 conf->upstream.store_access = NGX_CONF_UNSET_UINT;
1513 conf->upstream.buffering = NGX_CONF_UNSET; 1525 conf->upstream.buffering = NGX_CONF_UNSET;
1514 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; 1526 conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
1515 1527
1516 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; 1528 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
1517 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; 1529 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
1559 ngx_hash_init_t hash; 1571 ngx_hash_init_t hash;
1560 ngx_http_proxy_redirect_t *pr; 1572 ngx_http_proxy_redirect_t *pr;
1561 ngx_http_script_compile_t sc; 1573 ngx_http_script_compile_t sc;
1562 ngx_http_script_copy_code_t *copy; 1574 ngx_http_script_copy_code_t *copy;
1563 1575
1564 ngx_conf_merge_uint_value(conf->upstream.store, 1576 if (conf->upstream.store != 0) {
1565 prev->upstream.store, 0); 1577 ngx_conf_merge_value(conf->upstream.store,
1578 prev->upstream.store, 0);
1579
1580 if (conf->upstream.store_lengths == NULL) {
1581 conf->upstream.store_lengths = prev->upstream.store_lengths;
1582 conf->upstream.store_values = prev->upstream.store_values;
1583 }
1584 }
1585
1586 ngx_conf_merge_uint_value(conf->upstream.store_access,
1587 prev->upstream.store_access, 0600);
1566 1588
1567 ngx_conf_merge_value(conf->upstream.buffering, 1589 ngx_conf_merge_value(conf->upstream.buffering,
1568 prev->upstream.buffering, 1); 1590 prev->upstream.buffering, 1);
1569 1591
1570 ngx_conf_merge_value(conf->upstream.ignore_client_abort, 1592 ngx_conf_merge_value(conf->upstream.ignore_client_abort,
2369 return NGX_CONF_OK; 2391 return NGX_CONF_OK;
2370 } 2392 }
2371 2393
2372 2394
2373 static char * 2395 static char *
2396 ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
2397 {
2398 ngx_http_proxy_loc_conf_t *plcf = conf;
2399
2400 ngx_str_t *value;
2401 ngx_http_script_compile_t sc;
2402
2403 if (plcf->upstream.store != NGX_CONF_UNSET || plcf->upstream.store_lengths)
2404 {
2405 return "is duplicate";
2406 }
2407
2408 value = cf->args->elts;
2409
2410 if (ngx_strcmp(value[1].data, "on") == 0) {
2411 plcf->upstream.store = 1;
2412 return NGX_CONF_OK;
2413 }
2414
2415 if (ngx_strcmp(value[1].data, "off") == 0) {
2416 plcf->upstream.store = 0;
2417 return NGX_CONF_OK;
2418 }
2419
2420 /* include the terminating '\0' into script */
2421 value[1].len++;
2422
2423 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
2424
2425 sc.cf = cf;
2426 sc.source = &value[1];
2427 sc.lengths = &plcf->upstream.store_lengths;
2428 sc.values = &plcf->upstream.store_values;
2429 sc.variables = ngx_http_script_variables_count(&value[1]);;
2430 sc.complete_lengths = 1;
2431 sc.complete_values = 1;
2432
2433 if (ngx_http_script_compile(&sc) != NGX_OK) {
2434 return NGX_CONF_ERROR;
2435 }
2436
2437 return NGX_CONF_OK;
2438 }
2439
2440
2441 static char *
2374 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) 2442 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data)
2375 { 2443 {
2376 #if (NGX_FREEBSD) 2444 #if (NGX_FREEBSD)
2377 ssize_t *np = data; 2445 ssize_t *np = data;
2378 2446