Merge 7367d1face
into c33dedf10b
This commit is contained in:
commit
44ddf41110
4 changed files with 11 additions and 18 deletions
|
@ -1,5 +1,5 @@
|
|||
FROM nginx:1.14.1
|
||||
LABEL maintainer="Jason Wilder mail@jasonwilder.com"
|
||||
LABEL maintainer="Mitja Bombac mitja.bombac@gmail.com"
|
||||
|
||||
# Install wget and install/updates certificates
|
||||
RUN apt-get update \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FROM nginx:1.14.1-alpine
|
||||
LABEL maintainer="Jason Wilder mail@jasonwilder.com"
|
||||
LABEL maintainer="Mitja Bombac mitja.bombac@gmail.com"
|
||||
|
||||
# Install wget and install/updates certificates
|
||||
RUN apk add --no-cache --virtual .run-deps \
|
||||
|
|
|
@ -24,11 +24,11 @@ Provided your DNS is setup to forward foo.bar.com to the host running nginx-prox
|
|||
|
||||
The nginx-proxy images are available in two flavors.
|
||||
|
||||
#### jwilder/nginx-proxy:latest
|
||||
#### senzacionale/nginx-proxy:latest
|
||||
|
||||
This image uses the debian:jessie based nginx image.
|
||||
|
||||
$ docker pull jwilder/nginx-proxy:latest
|
||||
$ docker pull senzacionale/nginx-proxy:latest
|
||||
|
||||
#### jwilder/nginx-proxy:alpine
|
||||
|
||||
|
|
21
nginx.tmpl
21
nginx.tmpl
|
@ -9,17 +9,12 @@
|
|||
{{/* 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 }}
|
||||
{{ if .Network.IP }}
|
||||
server {{ .Network.IP }} down;
|
||||
{{ else }}
|
||||
server 127.0.0.1 down;
|
||||
{{ end }}
|
||||
server {{ .Network }} down;
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
|
||||
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
|
||||
|
@ -129,22 +124,20 @@ 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"))) }}
|
||||
{{ if eq $knownNetwork.Name $containerNetwork.Name }}
|
||||
## Can be connected 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) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
# Cannot connect to network of this container
|
||||
server 127.0.0.1 down;
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetworkIp) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue