Add support for additional allowed hosts in environment configuration

This commit is contained in:
Eduardo Silva
2025-04-22 17:02:43 -03:00
parent 06068fdc4c
commit 8708850143
8 changed files with 36 additions and 10 deletions

View File

@@ -21,10 +21,21 @@ if [ ! -f /app_secrets/rrdtool_key ]; then
cat /proc/sys/kernel/random/uuid > /app_secrets/rrdtool_key
fi
SERVER_HOSTNAME=$(echo $SERVER_ADDRESS | cut -d ':' -f 1)
EXTRA_ALLOWED_HOSTS_STRING=""
CSRF_EXTRA_TRUSTED_ORIGINS=""
if [ -n "$EXTRA_ALLOWED_HOSTS" ]; then
IFS=',' read -ra ADDR <<< "$EXTRA_ALLOWED_HOSTS"
for i in "${ADDR[@]}"; do
EXTRA_ALLOWED_HOSTS_STRING+=", '$(echo $i | cut -d ':' -f 1)'"
CSRF_EXTRA_TRUSTED_ORIGINS+=", 'https://$i'"
done
fi
cat > /app/wireguard_webadmin/production_settings.py <<EOL
DEBUG = $DEBUG_VALUE
ALLOWED_HOSTS = ['wireguard-webadmin', '$SERVER_ADDRESS']
CSRF_TRUSTED_ORIGINS = ['http://wireguard-webadmin', 'https://$SERVER_ADDRESS']
ALLOWED_HOSTS = ['wireguard-webadmin', '${SERVER_HOSTNAME}'${EXTRA_ALLOWED_HOSTS_STRING}]
CSRF_TRUSTED_ORIGINS = ['http://wireguard-webadmin', 'https://$SERVER_ADDRESS'${CSRF_EXTRA_TRUSTED_ORIGINS}]
SECRET_KEY = '$(openssl rand -base64 32)'
EOL