Merge a470ac7482 into 3afdd9d9e3
This commit is contained in:
commit
af691a68fb
2 changed files with 31 additions and 4 deletions
16
README.md
16
README.md
|
|
@ -163,6 +163,22 @@ nginx-proxy will then redirect all requests to a container where `VIRTUAL_HOST`
|
||||||
|
|
||||||
$ docker run -d -e VIRTUAL_HOST=foo.bar.com nginx
|
$ docker run -d -e VIRTUAL_HOST=foo.bar.com nginx
|
||||||
|
|
||||||
|
### Non-Docker Host
|
||||||
|
|
||||||
|
If you want to proxy a web server that is not a docker conatiner but still want the benefit of [jwilder/docker-gen](https://index.docker.io/u/jwilder/docker-gen/) and [letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion) you can use a dummy container that just provideds the necessary upstream address to generate the nginx config.
|
||||||
|
|
||||||
|
Start a [dummy container](https://hub.docker.com/r/cwempe/docker-dummy/) and define `VIRTUAL_HOST`, `UPSTREAM_NAME` (and `VIRTUAL_PORT` if the port is not 80) with the address of your web server.
|
||||||
|
Make sure nginx is able to connect to the web server.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker run -d \
|
||||||
|
-e VIRTUAL_HOST=foo.bar.com \
|
||||||
|
-e VIRTUAL_PORT=8080 \
|
||||||
|
-e UPSTREAM_NAME=webserver.local \
|
||||||
|
--rm \
|
||||||
|
cwempe/docker-dummy:latest
|
||||||
|
```
|
||||||
|
|
||||||
### Separate Containers
|
### Separate Containers
|
||||||
|
|
||||||
nginx-proxy can also be run as two separate containers using the [jwilder/docker-gen](https://hub.docker.com/r/jwilder/docker-gen)
|
nginx-proxy can also be run as two separate containers using the [jwilder/docker-gen](https://hub.docker.com/r/jwilder/docker-gen)
|
||||||
|
|
|
||||||
19
nginx.tmpl
19
nginx.tmpl
|
|
@ -16,7 +16,13 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else if .Network }}
|
{{ else if .Network }}
|
||||||
# {{ .Container.Name }}
|
# {{ .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;
|
server {{ .Network.IP }} down;
|
||||||
{{ else }}
|
{{ else }}
|
||||||
server 127.0.0.1 down;
|
server 127.0.0.1 down;
|
||||||
|
|
@ -184,9 +190,14 @@ upstream {{ $upstream_name }} {
|
||||||
|
|
||||||
{{ range $knownNetwork := $CurrentContainer.Networks }}
|
{{ range $knownNetwork := $CurrentContainer.Networks }}
|
||||||
{{ range $containerNetwork := $container.Networks }}
|
{{ range $containerNetwork := $container.Networks }}
|
||||||
{{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
|
{{ if (and (ne $containerNetwork.Name "ingress") (or (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host")) $container.Env.UPSTREAM_NAME)) }}
|
||||||
## Can be connected with "{{ $containerNetwork.Name }}" network
|
{{/* 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 only 1 port exposed, use that */}}
|
||||||
{{ if eq $addrLen 1 }}
|
{{ if eq $addrLen 1 }}
|
||||||
{{ $address := index $container.Addresses 0 }}
|
{{ $address := index $container.Addresses 0 }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue