Klaus Demo nginx / 72b9a31
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. Ruslan Ermilov 6 years ago
5 changed file(s) with 26 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
772772
773773 } else {
774774 u->resolved->host = url.host;
775 u->resolved->port = url.port;
776 u->resolved->no_port = url.no_port;
777 }
775 }
776
777 u->resolved->port = url.port;
778 u->resolved->no_port = url.no_port;
778779
779780 return NGX_OK;
780781 }
10141014
10151015 } else {
10161016 u->resolved->host = url.host;
1017 u->resolved->port = (in_port_t) (url.no_port ? port : url.port);
1018 u->resolved->no_port = url.no_port;
1019 }
1017 }
1018
1019 u->resolved->port = (in_port_t) (url.no_port ? port : url.port);
1020 u->resolved->no_port = url.no_port;
10201021
10211022 return NGX_OK;
10221023 }
568568
569569 } else {
570570 u->resolved->host = url.host;
571 u->resolved->port = url.port;
572 u->resolved->no_port = url.no_port;
573 }
571 }
572
573 u->resolved->port = url.port;
574 u->resolved->no_port = url.no_port;
574575
575576 return NGX_OK;
576577 }
770770
771771 } else {
772772 u->resolved->host = url.host;
773 u->resolved->port = url.port;
774 u->resolved->no_port = url.no_port;
775 }
773 }
774
775 u->resolved->port = url.port;
776 u->resolved->no_port = url.no_port;
776777
777778 return NGX_OK;
778779 }
632632 u->ssl_name = u->resolved->host;
633633 #endif
634634
635 host = &u->resolved->host;
636
635637 if (u->resolved->sockaddr) {
638
639 if (u->resolved->port == 0) {
640 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
641 "no port in upstream \"%V\"", host);
642 ngx_http_upstream_finalize_request(r, u,
643 NGX_HTTP_INTERNAL_SERVER_ERROR);
644 return;
645 }
636646
637647 if (ngx_http_upstream_create_round_robin_peer(r, u->resolved)
638648 != NGX_OK)
646656
647657 return;
648658 }
649
650 host = &u->resolved->host;
651659
652660 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
653661