Use Env.UPSTREAM_NAME if host is not a docker container
This commit is contained in:
parent
000a44772d
commit
4fe821db4d
1 changed files with 15 additions and 4 deletions
19
nginx.tmpl
19
nginx.tmpl
|
|
@ -13,7 +13,13 @@
|
|||
{{ end }}
|
||||
{{ else if .Network }}
|
||||
# {{ .Container.Name }}
|
||||
{{ if .Network.IP }}
|
||||
{{ if .Container.Env.UPSTREAM_NAME }}
|
||||
{{ if .Container.Env.VIRTUAL_PORT }}
|
||||
server {{ .Container.Env.UPSTREAM_NAME }}:{{ .Container.Env.VIRTUAL_PORT }};
|
||||
{{ else }}
|
||||
server {{ .Container.Env.UPSTREAM_NAME }};
|
||||
{{ end }}
|
||||
{{ else if .Network.IP }}
|
||||
server {{ .Network.IP }} down;
|
||||
{{ else }}
|
||||
server 127.0.0.1 down;
|
||||
|
|
@ -129,9 +135,14 @@ upstream {{ $upstream_name }} {
|
|||
|
||||
{{ range $knownNetwork := $CurrentContainer.Networks }}
|
||||
{{ range $containerNetwork := $container.Networks }}
|
||||
{{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
|
||||
## Can be connected with "{{ $containerNetwork.Name }}" network
|
||||
|
||||
{{ if (and (ne $containerNetwork.Name "ingress") (or (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host")) $container.Env.UPSTREAM_NAME)) }}
|
||||
{{/* Define $upstream_name if the host is not a docker container */}}
|
||||
{{ if $container.Env.UPSTREAM_NAME }}
|
||||
{{ $upstream_name := $container.Env.UPSTREAM_NAME }}
|
||||
## Host is not a docker container
|
||||
{{ else }}
|
||||
## Can be connected with "{{ $containerNetwork.Name }}" network
|
||||
{{ end }}
|
||||
{{/* If only 1 port exposed, use that */}}
|
||||
{{ if eq $addrLen 1 }}
|
||||
{{ $address := index $container.Addresses 0 }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue