Mercurial > hg > nginx
diff src/http/ngx_http_upstream.c @ 6303:a93345ee8f52
Upstream: fixed "no port" detection in evaluated upstreams.
If an upstream with variables evaluated to address without a port,
then instead of a "no port in upstream" error an attempt was made
to connect() which failed with EADDRNOTAVAIL.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Sat, 21 Nov 2015 10:44:07 +0300 |
parents | 4d5ac1a31d44 |
children | b1858fc47e3b |
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c Tue Nov 17 19:41:39 2015 +0300 +++ b/src/http/ngx_http_upstream.c Sat Nov 21 10:44:07 2015 +0300 @@ -633,8 +633,18 @@ u->ssl_name = u->resolved->host; #endif + host = &u->resolved->host; + if (u->resolved->sockaddr) { + 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; + } + if (ngx_http_upstream_create_round_robin_peer(r, u->resolved) != NGX_OK) { @@ -648,8 +658,6 @@ return; } - host = &u->resolved->host; - umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); uscfp = umcf->upstreams.elts;