Merge pull request #5473 from dokku/5341-ip-warn
Add warning when a user is attempting to deploy with an ipv4/ipv6 domain name and has the default nginx site file available
This commit is contained in:
35
plugins/domains/core-post-deploy
Executable file
35
plugins/domains/core-post-deploy
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
trigger-domains-core-post-deploy() {
|
||||||
|
declare desc="domains core-post-deploy plugin trigger"
|
||||||
|
declare trigger="core-post-deploy"
|
||||||
|
declare APP="$1"
|
||||||
|
|
||||||
|
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "/etc/nginx/sites-enabled/default" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
get_app_domains | while read -r domain; do
|
||||||
|
if [[ "$domain" =~ $RE_IPV4 ]]; then
|
||||||
|
dokku_log_warn "Detected IPv4 domain name with nginx proxy enabled."
|
||||||
|
dokku_log_warn "Ensure the default nginx site is removed before continuing."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$domain" =~ $RE_IPV6 ]]; then
|
||||||
|
dokku_log_warn "Detected IPv6 domain name with nginx proxy enabled."
|
||||||
|
dokku_log_warn "Ensure the default nginx site is removed before continuing."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger-domains-core-post-deploy "$@"
|
||||||
@@ -26,8 +26,6 @@ domains_setup() {
|
|||||||
local APP="$1"
|
local APP="$1"
|
||||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||||
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||||
local RE_IPV4="$(get_ipv4_regex)"
|
|
||||||
local RE_IPV6="$(get_ipv6_regex)"
|
|
||||||
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
|
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
|
||||||
|
|
||||||
if [[ ! -f $APP_VHOST_PATH ]]; then
|
if [[ ! -f $APP_VHOST_PATH ]]; then
|
||||||
@@ -264,8 +262,6 @@ is_global_vhost_enabled() {
|
|||||||
declare desc="returns true if we have a valid global vhost set; otherwise returns false"
|
declare desc="returns true if we have a valid global vhost set; otherwise returns false"
|
||||||
local GLOBAL_VHOSTS=$(get_global_vhosts)
|
local GLOBAL_VHOSTS=$(get_global_vhosts)
|
||||||
local GLOBAL_VHOSTS_ENABLED=false
|
local GLOBAL_VHOSTS_ENABLED=false
|
||||||
local RE_IPV4="$(get_ipv4_regex)"
|
|
||||||
local RE_IPV6="$(get_ipv6_regex)"
|
|
||||||
|
|
||||||
while read -r GLOBAL_VHOST; do
|
while read -r GLOBAL_VHOST; do
|
||||||
if (is_valid_hostname "$GLOBAL_VHOST"); then
|
if (is_valid_hostname "$GLOBAL_VHOST"); then
|
||||||
|
|||||||
@@ -355,3 +355,21 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(domains) verify warning on ipv4/ipv6 domain name" {
|
||||||
|
touch /etc/nginx/sites-enabled/default
|
||||||
|
rm "$DOKKU_ROOT/VHOST"
|
||||||
|
echo "127.0.0.1" >"$DOKKU_ROOT/VHOST"
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "Detected IPv4 domain name with nginx proxy enabled."
|
||||||
|
|
||||||
|
rm -f /etc/nginx/sites-enabled/default
|
||||||
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "Detected IPv4 domain name with nginx proxy enabled." 0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user