diff options
| author | Ruslan Ermilov <ru@nginx.com> | 2015-11-21 10:44:07 +0300 |
|---|---|---|
| committer | Ruslan Ermilov <ru@nginx.com> | 2015-11-21 10:44:07 +0300 |
| commit | 72b9a317d2983b3127b8cce21236af8409ff732a (patch) | |
| tree | 77227aec49ac06df16d3477708e2488bb2421f3d /src/http/ngx_http_upstream.c | |
| parent | cb5306984b3f2eacb155dfee17b1b9e3165c9168 (diff) | |
| download | nginx-72b9a317d2983b3127b8cce21236af8409ff732a.tar.gz nginx-72b9a317d2983b3127b8cce21236af8409ff732a.tar.bz2 | |
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.
Diffstat (limited to '')
| -rw-r--r-- | src/http/ngx_http_upstream.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 74fffd5c8..8a9fbac46 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -633,8 +633,18 @@ ngx_http_upstream_init_request(ngx_http_request_t *r) 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 @@ ngx_http_upstream_init_request(ngx_http_request_t *r) return; } - host = &u->resolved->host; - umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); uscfp = umcf->upstreams.elts; |
