comparison src/http/modules/ngx_http_proxy_module.c @ 2989:dff9764eaca2

do auto redirect for proxy_pass/fastcgi_pass with variables
author Igor Sysoev <igor@sysoev.ru>
date Mon, 20 Jul 2009 11:44:38 +0000
parents fe484c0be7c0
children 95972b9e790b
comparison
equal deleted inserted replaced
2988:b535ece5e350 2989:dff9764eaca2
2590 return "is duplicate"; 2590 return "is duplicate";
2591 } 2591 }
2592 2592
2593 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); 2593 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
2594 2594
2595 clcf->handler = ngx_http_proxy_handler;
2596
2597 if (clcf->name.data[clcf->name.len - 1] == '/') {
2598 clcf->auto_redirect = 1;
2599 }
2600
2595 value = cf->args->elts; 2601 value = cf->args->elts;
2596 2602
2597 url = &value[1]; 2603 url = &value[1];
2598 2604
2599 n = ngx_http_script_variables_count(url); 2605 n = ngx_http_script_variables_count(url);
2618 if (ngx_http_proxy_set_ssl(cf, plcf) != NGX_OK) { 2624 if (ngx_http_proxy_set_ssl(cf, plcf) != NGX_OK) {
2619 return NGX_CONF_ERROR; 2625 return NGX_CONF_ERROR;
2620 } 2626 }
2621 #endif 2627 #endif
2622 2628
2623 clcf->handler = ngx_http_proxy_handler;
2624
2625 return NGX_CONF_OK; 2629 return NGX_CONF_OK;
2626 } 2630 }
2627 2631
2628 if (ngx_strncasecmp(url->data, (u_char *) "http://", 7) == 0) { 2632 if (ngx_strncasecmp(url->data, (u_char *) "http://", 7) == 0) {
2629 add = 7; 2633 add = 7;
2665 plcf->vars.schema.len = add; 2669 plcf->vars.schema.len = add;
2666 plcf->vars.schema.data = url->data; 2670 plcf->vars.schema.data = url->data;
2667 plcf->vars.key_start = plcf->vars.schema; 2671 plcf->vars.key_start = plcf->vars.schema;
2668 2672
2669 ngx_http_proxy_set_vars(&u, &plcf->vars); 2673 ngx_http_proxy_set_vars(&u, &plcf->vars);
2670
2671 clcf->handler = ngx_http_proxy_handler;
2672 2674
2673 plcf->location = clcf->name; 2675 plcf->location = clcf->name;
2674 2676
2675 if (clcf->named 2677 if (clcf->named
2676 #if (NGX_PCRE) 2678 #if (NGX_PCRE)
2691 plcf->location.len = 0; 2693 plcf->location.len = 0;
2692 } 2694 }
2693 2695
2694 plcf->url = *url; 2696 plcf->url = *url;
2695 2697
2696 if (clcf->name.data[clcf->name.len - 1] == '/') {
2697 clcf->auto_redirect = 1;
2698 }
2699
2700 return NGX_CONF_OK; 2698 return NGX_CONF_OK;
2701 } 2699 }
2702 2700
2703 2701
2704 static char * 2702 static char *