Skip to content
This repository was archived by the owner on Feb 21, 2019. It is now read-only.

Tweaks I needed for my installation #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nginx/certs
nginx/conf.d
nginx/vhost.d
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
nginx:
image: nginx:stable-alpine
container_name: nginx
restart: unless-stopped
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/vhost.d:/etc/nginx/vhost.d
Expand All @@ -13,6 +14,7 @@ nginx:
nginx-gen:
image: jwilder/docker-gen
container_name: nginx-gen
restart: unless-stopped
command: "-notify-sighup nginx -watch -only-exposed -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf"
volumes_from: [nginx]
volumes:
Expand All @@ -21,6 +23,7 @@ nginx-gen:
nginx-letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-letsencrypt
restart: unless-stopped
links: [nginx-gen]
volumes_from: [nginx]
volumes:
Expand Down
6 changes: 3 additions & 3 deletions nginx/templates/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
{{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
{{ else if .Address.IP }}
# {{ .Container.Name }}
server {{ .Address.IP }}:{{ .Address.Port }};
server {{ .Address.IP }}:{{ .Address.HostPort }};
{{ else }}
# {{ .Container.Name }}
server {{ .Container.Name }}:{{ .Address.Port }};
server {{ .Container.Name }}:{{ .Address.HostPort }};
{{ end }}
{{ else }}
# {{ .Container.Name }}
Expand Down Expand Up @@ -85,7 +85,7 @@ upstream {{ $host }} {
{{/* 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 }}
{{ $address := where $container.Addresses "HostPort" $port | first }}
{{ template "upstream" (dict "Container" $container "Address" $address) }}
{{ end }}
{{ end }}
Expand Down