# HG changeset patch # User Igor Sysoev # Date 1301913801 0 # Node ID 502a6b0acf3f9e5f489494ffc4aae2223bec8fe4 # Parent 7562ee4feb745c5487be3864b21b5fe03a5d38a5 fix case when a host in fastcgi_pass, scgi_pass, and uwsgi_pass is given by expression and refers to a defined upstream diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -636,12 +636,6 @@ ngx_http_fastcgi_eval(ngx_http_request_t 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 } else { u->resolved->host = url.host; u->resolved->port = url.port; + u->resolved->no_port = url.no_port; } return NGX_OK; diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -458,12 +458,6 @@ ngx_http_scgi_eval(ngx_http_request_t *r 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 } else { u->resolved->host = url.host; u->resolved->port = url.port; + u->resolved->no_port = url.no_port; } return NGX_OK; diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c --- a/src/http/modules/ngx_http_uwsgi_module.c +++ b/src/http/modules/ngx_http_uwsgi_module.c @@ -491,12 +491,6 @@ ngx_http_uwsgi_eval(ngx_http_request_t * 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 * } else { u->resolved->host = url.host; u->resolved->port = url.port; + u->resolved->no_port = url.no_port; } return NGX_OK; diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -574,6 +574,14 @@ ngx_http_upstream_init_request(ngx_http_ } } + 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);