Add guschin.info VirtualHost alongside xmpp.guschin.info

Users can now register as name@guschin.info or name@xmpp.guschin.info.
Added Let's Encrypt cert mounting and install for guschin.info domain.
Refactored entrypoint cert install into reusable function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mguschin
2026-03-02 07:56:48 +03:00
parent eb8a2e3145
commit 173f3a9705
3 changed files with 41 additions and 26 deletions

View File

@@ -38,30 +38,36 @@ fi
# (directories are already created in Dockerfile with proper ownership)
touch /var/log/prosody/prosody.log /var/log/prosody/prosody.err 2>/dev/null || true
# Copy Let's Encrypt certificate to prosody certs directory if available
CERT_PATH="/etc/prosody/certs/xmpp.guschin.info.crt"
KEY_PATH="/etc/prosody/certs/xmpp.guschin.info.key"
LETSENCRYPT_CERT="/etc/prosody/certs/letsencrypt/live/xmpp.guschin.info/fullchain.pem"
LETSENCRYPT_KEY="/etc/prosody/certs/letsencrypt/live/xmpp.guschin.info/privkey.pem"
# Copy Let's Encrypt certificates to prosody certs directory
install_cert() {
local domain="$1"
local cert_path="/etc/prosody/certs/${domain}.crt"
local key_path="/etc/prosody/certs/${domain}.key"
local le_cert="/etc/prosody/certs/letsencrypt/live/${domain}/fullchain.pem"
local le_key="/etc/prosody/certs/letsencrypt/live/${domain}/privkey.pem"
if [ -f "$LETSENCRYPT_CERT" ] && [ -f "$LETSENCRYPT_KEY" ]; then
echo "Setting up Let's Encrypt certificate..."
cp "$LETSENCRYPT_CERT" "$CERT_PATH"
cp "$LETSENCRYPT_KEY" "$KEY_PATH"
chmod 644 "$CERT_PATH"
chmod 600 "$KEY_PATH"
chown prosody:prosody "$CERT_PATH" "$KEY_PATH"
echo "Let's Encrypt certificate successfully installed"
elif [ ! -f "$CERT_PATH" ] || [ ! -f "$KEY_PATH" ]; then
echo "Let's Encrypt certificate not found, generating self-signed certificate..."
openssl req -x509 -newkey rsa:4096 -keyout "$KEY_PATH" -out "$CERT_PATH" \
-days 365 -nodes -subj "/CN=xmpp.guschin.info"
chmod 600 "$KEY_PATH"
chmod 644 "$CERT_PATH"
chown prosody:prosody "$CERT_PATH" "$KEY_PATH"
else
echo "Using existing certificates"
fi
if [ -f "$le_cert" ] && [ -f "$le_key" ]; then
echo "Setting up Let's Encrypt certificate for ${domain}..."
cp "$le_cert" "$cert_path"
cp "$le_key" "$key_path"
chmod 644 "$cert_path"
chmod 600 "$key_path"
chown prosody:prosody "$cert_path" "$key_path"
echo "Let's Encrypt certificate for ${domain} installed"
elif [ ! -f "$cert_path" ] || [ ! -f "$key_path" ]; then
echo "Let's Encrypt certificate for ${domain} not found, generating self-signed..."
openssl req -x509 -newkey rsa:4096 -keyout "$key_path" -out "$cert_path" \
-days 365 -nodes -subj "/CN=${domain}"
chmod 600 "$key_path"
chmod 644 "$cert_path"
chown prosody:prosody "$cert_path" "$key_path"
else
echo "Using existing certificates for ${domain}"
fi
}
install_cert "xmpp.guschin.info"
install_cert "guschin.info"
echo "Starting Prosody..."