From f3b04032a8ed8731f7e67b2a3926b4f12c779a87 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 22 Nov 2022 23:43:28 -0500 Subject: [PATCH] feat: add warning when a user is attempting to deploy with an ipv4/ipv6 domain name and has the default nginx site file available This might cause an app to not load for users, causing confusion on first use. Closes #5341 --- plugins/domains/core-post-deploy | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 plugins/domains/core-post-deploy diff --git a/plugins/domains/core-post-deploy b/plugins/domains/core-post-deploy new file mode 100755 index 000000000..d564a6ce6 --- /dev/null +++ b/plugins/domains/core-post-deploy @@ -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 IPv4 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 "$@"