@@ -72,6 +72,8 @@ server {
7272
7373{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
7474
75+ {{ $host := trim $host }}
76+
7577upstream {{ $host }} {
7678{{ range $container := $containers }}
7779 {{ $addrLen := len $container.Addresses }}
@@ -92,7 +94,7 @@ upstream {{ $host }} {
9294{{ $default_server := index (dict $host "" $default_host "default_server") $host }}
9395
9496{{/* Get the VIRTUAL_PROTO defined by containers w/ the same vhost, falling back to "http" */}}
95- {{ $proto := or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http" }}
97+ {{ $proto := or (trim ( first (groupByKeys $containers "Env.VIRTUAL_PROTO") )) "http" }}
9698
9799{{/* Get the first cert name defined by containers w/ the same vhost */}}
98100{{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }}
@@ -144,7 +146,7 @@ server {
144146 {{ end }}
145147
146148 location / {
147- proxy_pass {{ trim $proto }}://{{ trim $host }};
149+ proxy_pass {{ $proto }}://{{ $host }};
148150 {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
149151 auth_basic "Restricted {{ $host }}";
150152 auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
@@ -170,7 +172,7 @@ server {
170172 {{ end }}
171173
172174 location / {
173- proxy_pass {{ trim $proto }}://{{ trim $host }};
175+ proxy_pass {{ $proto }}://{{ $host }};
174176 {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
175177 auth_basic "Restricted {{ $host }}";
176178 auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
0 commit comments