]> git.kaiwu.me - nginx.git/commitdiff
fix case when a host in fastcgi_pass, scgi_pass, and uwsgi_pass
authorIgor Sysoev <igor@sysoev.ru>
Mon, 4 Apr 2011 10:43:21 +0000 (10:43 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 4 Apr 2011 10:43:21 +0000 (10:43 +0000)
is given by expression and refers to a defined upstream

src/http/modules/ngx_http_fastcgi_module.c
src/http/modules/ngx_http_scgi_module.c
src/http/modules/ngx_http_uwsgi_module.c
src/http/ngx_http_upstream.c

index 12a1e81d89965c45d28cdaf6c42e4d5e6b204329..12d5b1d8f2bffe256bce827608f452c05714f138 100644 (file)
@@ -636,12 +636,6 @@ ngx_http_fastcgi_eval(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf)
         return NGX_ERROR;
     }
 
-    if (url.no_port) {
-        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
-                      "no port in upstream \"%V\"", &url.url);
-        return NGX_ERROR;
-    }
-
     u = r->upstream;
 
     u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
@@ -658,6 +652,7 @@ ngx_http_fastcgi_eval(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf)
     } else {
         u->resolved->host = url.host;
         u->resolved->port = url.port;
+        u->resolved->no_port = url.no_port;
     }
 
     return NGX_OK;
index d831e27c2b1077c3bc637600b74a1c02a1ffc65a..d745551f2a4479b2992be1c4073b80a9ca5c0db0 100644 (file)
@@ -458,12 +458,6 @@ ngx_http_scgi_eval(ngx_http_request_t *r, ngx_http_scgi_loc_conf_t * scf)
         return NGX_ERROR;
     }
 
-    if (url.no_port) {
-        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
-                      "no port in upstream \"%V\"", &url.url);
-        return NGX_ERROR;
-    }
-
     u = r->upstream;
 
     u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
@@ -480,6 +474,7 @@ ngx_http_scgi_eval(ngx_http_request_t *r, ngx_http_scgi_loc_conf_t * scf)
     } else {
         u->resolved->host = url.host;
         u->resolved->port = url.port;
+        u->resolved->no_port = url.no_port;
     }
 
     return NGX_OK;
index a2529131b880d891f3af9fd9c2a845e087bb814c..cd3c7c1244da68bddd00d2539ee86270181e9b72 100644 (file)
@@ -491,12 +491,6 @@ ngx_http_uwsgi_eval(ngx_http_request_t *r, ngx_http_uwsgi_loc_conf_t * uwcf)
         return NGX_ERROR;
     }
 
-    if (url.no_port) {
-        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
-                      "no port in upstream \"%V\"", &url.url);
-        return NGX_ERROR;
-    }
-
     u = r->upstream;
 
     u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
@@ -513,6 +507,7 @@ ngx_http_uwsgi_eval(ngx_http_request_t *r, ngx_http_uwsgi_loc_conf_t * uwcf)
     } else {
         u->resolved->host = url.host;
         u->resolved->port = url.port;
+        u->resolved->no_port = url.no_port;
     }
 
     return NGX_OK;
index e8d87738fdd8c1d0589413d23ee7d412c5e8f881..dc2d0c0feb5db651f9623555a23a885809fd6460 100644 (file)
@@ -574,6 +574,14 @@ ngx_http_upstream_init_request(ngx_http_request_t *r)
             }
         }
 
+        if (u->resolved->port == 0) {
+            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+                          "no port in upstream \"%V\"", host);
+            ngx_http_upstream_finalize_request(r, u,
+                                               NGX_HTTP_INTERNAL_SERVER_ERROR);
+            return;
+        }
+
         temp.name = *host;
 
         ctx = ngx_resolve_start(clcf->resolver, &temp);