diff src/http/modules/ngx_http_proxy_module.c @ 3425:0189a8f4c7c3 stable-0.7

merge r2990, r3324, r3384, r3419: various proxy/FastCGI fixes: *) do auto redirect for proxy_pass/fastcgi_pass with variables *) allow "proxy_pass http://$backend" without URI part *) add conf/fastcgi.conf *) delete u->cleanup mark, this fixes large values in $upstream_response_time, the bug had been introduced in r3246
author Igor Sysoev <igor@sysoev.ru>
date Mon, 01 Feb 2010 14:01:24 +0000
parents 61962127b166
children 3354dfba9da4
line wrap: on
line diff
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -717,17 +717,22 @@ ngx_http_proxy_eval(ngx_http_request_t *
         return NGX_ERROR;
     }
 
-    if (url.uri.len && url.uri.data[0] == '?') {
-        p = ngx_pnalloc(r->pool, url.uri.len + 1);
-        if (p == NULL) {
-            return NGX_ERROR;
+    if (url.uri.len) {
+        if (url.uri.data[0] == '?') {
+            p = ngx_pnalloc(r->pool, url.uri.len + 1);
+            if (p == NULL) {
+                return NGX_ERROR;
+            }
+
+            *p++ = '/';
+            ngx_memcpy(p, url.uri.data, url.uri.len);
+
+            url.uri.len++;
+            url.uri.data = p - 1;
         }
 
-        *p++ = '/';
-        ngx_memcpy(p, url.uri.data, url.uri.len);
-
-        url.uri.len++;
-        url.uri.data = p - 1;
+    } else {
+        url.uri = r->unparsed_uri;
     }
 
     ctx->vars.key_start = u->schema;
@@ -2585,6 +2590,12 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
 
     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
 
+    clcf->handler = ngx_http_proxy_handler;
+
+    if (clcf->name.data[clcf->name.len - 1] == '/') {
+        clcf->auto_redirect = 1;
+    }
+
     value = cf->args->elts;
 
     url = &value[1];
@@ -2613,8 +2624,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
         }
 #endif
 
-        clcf->handler = ngx_http_proxy_handler;
-
         return NGX_CONF_OK;
     }
 
@@ -2661,8 +2670,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
 
     ngx_http_proxy_set_vars(&u, &plcf->vars);
 
-    clcf->handler = ngx_http_proxy_handler;
-
     plcf->location = clcf->name;
 
     if (clcf->named
@@ -2686,10 +2693,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
 
     plcf->url = *url;
 
-    if (clcf->name.data[clcf->name.len - 1] == '/') {
-        clcf->auto_redirect = 1;
-    }
-
     return NGX_CONF_OK;
 }