rewritten upstream
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index 82173e4..89937ef 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -61,10 +61,17 @@
/* an upstream implicitly defined by proxy_pass, etc. */
+ if (us->port == 0 && us->default_port == 0) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "no port in upstream \"%V\" in %s:%ui",
+ &us->host, us->file_name.data, us->line);
+ return NGX_ERROR;
+ }
+
ngx_memzero(&u, sizeof(ngx_url_t));
u.host = us->host;
- u.portn = us->port;
+ u.port = us->port ? us->port : us->default_port;
if (ngx_inet_resolve_host(cf, &u) != NGX_OK) {
if (u.err) {
@@ -76,13 +83,6 @@
return NGX_ERROR;
}
- if (us->port == 0) {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "no port in upstream \"%V\" in %s:%ui",
- &us->host, us->file_name.data, us->line);
- return NGX_ERROR;
- }
-
n = u.naddrs;
peers = ngx_pcalloc(cf->pool, sizeof(ngx_http_upstream_rr_peers_t)