Skip to content

Commit 0409fc3

Browse files
committed
subdomains for auto-generated hostnames
1 parent 3c38cbc commit 0409fc3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ domain, prefix a dot `.` to the provided hostname. For instance setting
4747
`VIRTUAL_HOST=.myrailsapp.docker` will also make your app avaiable at
4848
`*.myrailsapp.docker`.
4949

50+
This happens automatically for the auto-generated docker-compose hostnames.
51+
5052
### SSL Support
5153

5254
SSL is supported using single host certificates using naming conventions.

nginx.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,11 @@ server {
166166
{{ range $project, $projContainers := groupByLabel $ "com.docker.compose.project" }}
167167
{{ range $service, $containers := groupByLabel $projContainers "com.docker.compose.service" }}
168168
{{ $host := printf "%s.%s.%s" $service $project $TLD }}
169+
{{ $dottedHost := printf ".%s" $host }}
169170
{{/* Don't create the implicit host if an explicit VIRTUAL_HOST with the same name has been defined */}}
170-
{{ if eq 0 (len (where $ "Env.VIRTUAL_HOST" $host)) }}
171+
{{ if and (eq 0 (len (where $ "Env.VIRTUAL_HOST" $host))) (eq 0 (len (where $ "Env.VIRTUAL_HOST" $dottedHost))) }}
171172
{{ $container := first $containers }}
172-
{{ template "server" (dict "Containers" $containers "Host" $host) }}
173+
{{ template "server" (dict "Containers" $containers "Host" $dottedHost) }}
173174
{{ end }}
174175
{{ end }}
175176
{{ end }}

0 commit comments

Comments
 (0)