Added DEFAULT_IP env variable
This commit is contained in:
parent
619943ac1e
commit
ca6b323654
1 changed files with 6 additions and 5 deletions
|
|
@ -9,11 +9,11 @@
|
|||
{{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
|
||||
{{ else if .Network }}
|
||||
# {{ .Container.Name }}
|
||||
server {{ .Network.IP }}:{{ .Address.Port }};
|
||||
server {{ .Network }}:{{ .Address.Port }};
|
||||
{{ end }}
|
||||
{{ else if .Network }}
|
||||
# {{ .Container.Name }}
|
||||
server {{ .Network.IP }} down;
|
||||
server {{ .Network }} down;
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
|
@ -111,15 +111,16 @@ upstream {{ $upstream_name }} {
|
|||
{{ if eq $knownNetwork.Name $containerNetwork.Name }}
|
||||
## Can be connect with "{{ $containerNetwork.Name }}" network
|
||||
|
||||
{{ $containerNetworkIp := or $container.Env.DEFAULT_IP $containerNetwork.IP }}
|
||||
{{/* If only 1 port exposed, use that */}}
|
||||
{{ if eq $addrLen 1 }}
|
||||
{{ $address := index $container.Addresses 0 }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetworkIp) }}
|
||||
{{/* 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" }}
|
||||
{{ $address := where $container.Addresses "Port" $port | first }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetworkIp) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue