Merge 83ddc6a239
into 53ef90a2f6
This commit is contained in:
commit
f4a5b6a31c
1 changed files with 26 additions and 0 deletions
26
nginx.tmpl
26
nginx.tmpl
|
@ -1,5 +1,31 @@
|
||||||
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
|
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
|
||||||
|
|
||||||
|
{{ define "upstream" }}
|
||||||
|
{{ $rancherIP := or (index .Container.Labels "io.rancher.container.ip") "" }}
|
||||||
|
{{ if .Address }}
|
||||||
|
{{/* If we got the containers from swarm and this container's port is published to host, use host IP:PORT */}}
|
||||||
|
{{ if and .Container.Node.ID .Address.HostPort }}
|
||||||
|
# {{ .Container.Node.Name }}/{{ .Container.Name }}
|
||||||
|
server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }};
|
||||||
|
{{/* 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 }};
|
||||||
|
{{ end }}
|
||||||
|
{{ else if $rancherIP }}
|
||||||
|
# rancher: {{ index .Container.Labels "io.rancher.container.name" }} {{ printf "%s" $rancherIP }}
|
||||||
|
{{ $port := coalesce .Container.Env.VIRTUAL_PORT "80" }}
|
||||||
|
server {{ printf "%s" (index (splitN $rancherIP "/" 2) 0) }}:{{ printf "%s" $port }};
|
||||||
|
{{ else if .Network }}
|
||||||
|
# {{ .Container.Name }}
|
||||||
|
{{ if .Network.IP }}
|
||||||
|
server {{ .Network.IP }} down;
|
||||||
|
{{ else }}
|
||||||
|
server 127.0.0.1 down;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
{{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }}
|
{{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }}
|
||||||
{{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }}
|
{{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }}
|
||||||
{{ $debug_all := $.Env.DEBUG }}
|
{{ $debug_all := $.Env.DEBUG }}
|
||||||
|
|
Loading…
Reference in a new issue