Add support for vhosts.d/defaults file with default vhost options

- Only used if it exists and a vhost-specific one doesn't
This commit is contained in:
Richard Bateman 2015-08-14 11:34:56 -06:00
parent d07a7d7487
commit b131b00e19
2 changed files with 9 additions and 0 deletions

View file

@ -193,3 +193,8 @@ If you are using multiple hostnames for a single container (e.g. `VIRTUAL_HOST=e
$ { echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } > /path/to/vhost.d/www.example.com $ { echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } > /path/to/vhost.d/www.example.com
$ ln -s /path/to/vhost.d/www.example.com /path/to/vhost.d/example.com $ ln -s /path/to/vhost.d/www.example.com /path/to/vhost.d/example.com
#### Per-VIRTUAL_HOST default configuration
If you want most of your virtual hosts to use a default single configuration and then override on a few specific ones, add those settings to the `/etc/nginx/vhost.d/default` file. This file
will be used on any virtual host which does not have a `/etc/nginx/vhost.d/{VIRTUAL_HOST}` file associated with it.

View file

@ -125,6 +125,8 @@ server {
{{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }} {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
include {{ printf "/etc/nginx/vhost.d/%s" $host }}; include {{ printf "/etc/nginx/vhost.d/%s" $host }};
{{ else if (exists /etc/vhost.d/defaults) }}
include /etc/nginx/vhost.d/defaults
{{ end }} {{ end }}
location / { location / {
@ -143,6 +145,8 @@ server {
{{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }} {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
include {{ printf "/etc/nginx/vhost.d/%s" $host }}; include {{ printf "/etc/nginx/vhost.d/%s" $host }};
{{ else if (exists /etc/vhost.d/defaults) }}
include /etc/nginx/vhost.d/defaults
{{ end }} {{ end }}
location / { location / {