Skip to content

Commit

Permalink
Support multiple VIRTUAL_PORT alongside VIRTUAL_HOST
Browse files Browse the repository at this point in the history
See nginx-proxy/nginx-proxy#59

Final solution: VIRTUAL_HOST="example.com:8080,example.org:8081"
  • Loading branch information
julianxhokaxhiu committed Feb 14, 2017
1 parent 430ad0f commit cb2be22
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ upstream {{ $host }} {
{{ if eq $addrLen 1 }}
{{ $address := index $container.Addresses 0 }}
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
{{/* If more than one port exposed, use the one matching after the colon in VIRTUAL_HOST env var */}}
{{ else if (and ($port ) (ne $port $host) ) }}
{{ range $address := $container.Addresses }}
{{ if eq $address.Port $port }}
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
{{ end }}
{{ end }}
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}}
{{ else }}
{{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }}
Expand Down

0 comments on commit cb2be22

Please sign in to comment.