mirror of
https://github.com/nginx/nginx.git
synced 2025-06-17 17:20:42 +08:00
fix case when a host in fastcgi_pass, scgi_pass, and uwsgi_pass
is given by expression and refers to a defined upstream
This commit is contained in:
parent
450c981ab9
commit
fde7d51392
@ -636,12 +636,6 @@ ngx_http_fastcgi_eval(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf)
|
|||||||
return NGX_ERROR;
|
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 = r->upstream;
|
||||||
|
|
||||||
u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
|
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 {
|
} else {
|
||||||
u->resolved->host = url.host;
|
u->resolved->host = url.host;
|
||||||
u->resolved->port = url.port;
|
u->resolved->port = url.port;
|
||||||
|
u->resolved->no_port = url.no_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
@ -458,12 +458,6 @@ ngx_http_scgi_eval(ngx_http_request_t *r, ngx_http_scgi_loc_conf_t * scf)
|
|||||||
return NGX_ERROR;
|
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 = r->upstream;
|
||||||
|
|
||||||
u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
|
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 {
|
} else {
|
||||||
u->resolved->host = url.host;
|
u->resolved->host = url.host;
|
||||||
u->resolved->port = url.port;
|
u->resolved->port = url.port;
|
||||||
|
u->resolved->no_port = url.no_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
@ -491,12 +491,6 @@ ngx_http_uwsgi_eval(ngx_http_request_t *r, ngx_http_uwsgi_loc_conf_t * uwcf)
|
|||||||
return NGX_ERROR;
|
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 = r->upstream;
|
||||||
|
|
||||||
u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
|
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 {
|
} else {
|
||||||
u->resolved->host = url.host;
|
u->resolved->host = url.host;
|
||||||
u->resolved->port = url.port;
|
u->resolved->port = url.port;
|
||||||
|
u->resolved->no_port = url.no_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
@ -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;
|
temp.name = *host;
|
||||||
|
|
||||||
ctx = ngx_resolve_start(clcf->resolver, &temp);
|
ctx = ngx_resolve_start(clcf->resolver, &temp);
|
||||||
|
Loading…
Reference in New Issue
Block a user