allow users to add a domain to an app if there is no global vhost

This commit is contained in:
Michael Hobbs
2015-01-11 14:35:02 -08:00
parent da465a61dd
commit 80d13c0005
5 changed files with 85 additions and 18 deletions

View File

@@ -21,10 +21,12 @@ RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,4}:${RE_IPV4}" # TEST: 2
[[ -f "$DOKKU_ROOT/VHOST" ]] && GLOBAL_VHOST=$(< "$DOKKU_ROOT/VHOST")
if [[ -n "$NO_VHOST" ]] || [[ -z "$GLOBAL_VHOST" ]]; then
if [[ -n "$NO_VHOST" ]]; then
echo true # bind to external ip. VHOST is disabled
elif [[ "$GLOBAL_VHOST" =~ $RE_IPV4 ]] || [[ "$GLOBAL_VHOST" =~ $RE_IPV6 ]]; then
echo true # bind to external ip. GLOBAL_VHOST is somehow an IPv4 or IPv6 address
elif [[ -z "$GLOBAL_VHOST" ]] && [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
echo true # bind to external ip. no GLOBAL_VHOST and no app vhost
elif [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
echo false # bind to docker ip. this app has a vhost defined
else

View File

@@ -29,7 +29,7 @@ case "$1" in
[[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV
if [[ ! -n "$NO_VHOST" ]]; then
if [[ ! -n "$NO_VHOST" ]] && [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
NONSSL_VHOSTS=$(cat $VHOST_PATH)
if [[ -e "$SSL/server.crt" ]] && [[ -e "$SSL/server.key" ]]; then
SSL_INUSE="$SSL"
@@ -86,14 +86,14 @@ EOF
fi
else
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
echo "-----> NO_VHOST set, deleting $APP/VHOST"
echo "-----> VHOST support disabled, deleting $APP/VHOST"
rm "$DOKKU_ROOT/$APP/VHOST"
fi
if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
echo "-----> NO_VHOST set, deleting nginx.conf"
echo "-----> VHOST support disabled, deleting nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf"
echo "-----> NO_VHOST set, reloading nginx after nginx.conf deletion"
echo "-----> VHOST support disabled, reloading nginx after nginx.conf deletion"
restart_nginx
fi
fi