From ff5bd193356755dd69acb9a2b77188c2ff95d943 Mon Sep 17 00:00:00 2001 From: Your Name <119736744+aborayan2022@users.noreply.github.com> Date: Tue, 17 Mar 2026 13:03:59 +0200 Subject: [PATCH] feat: implement SSL support with Let's Encrypt and update Nginx configuration --- backend/celerybeat-schedule | Bin 16384 -> 16384 bytes docker-compose.yml | 10 ++ fixed-ssl.md | 273 ++++++++++++++++++++++++++++++++++++ nginx/nginx.conf | 27 +++- scripts/init-letsencrypt.sh | 102 ++++++++++++++ 5 files changed, 410 insertions(+), 2 deletions(-) create mode 100644 fixed-ssl.md create mode 100644 scripts/init-letsencrypt.sh diff --git a/backend/celerybeat-schedule b/backend/celerybeat-schedule index 838ebe93d2d25b062bec1b504daf3f27aac97d25..f4d7d35e154f202b2fab00a3d3c0480d8277cc0d 100644 GIT binary patch delta 28 jcmZo@U~Fh$+~8ouF36#%%y!s&vb#|r /dev/null 2>&1 || fail "docker is not installed" +command -v docker compose > /dev/null 2>&1 && COMPOSE="docker compose" || COMPOSE="docker-compose" + +# ── Step 1: Create required directories ── +info "Creating certbot directories …" +mkdir -p "$DATA_PATH/conf" "$DATA_PATH/www" +ok "Directories ready" + +# ── Step 2: Download recommended TLS parameters ── +if [ ! -e "$DATA_PATH/conf/options-ssl-nginx.conf" ]; then + info "Downloading recommended TLS parameters …" + curl -sSf https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf \ + -o "$DATA_PATH/conf/options-ssl-nginx.conf" + curl -sSf https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem \ + -o "$DATA_PATH/conf/ssl-dhparams.pem" + ok "TLS parameters saved" +fi + +# ── Step 3: Create temporary self-signed certificate ── +LIVE_DIR="$DATA_PATH/conf/live/dociva.io" +if [ ! -e "$LIVE_DIR/fullchain.pem" ]; then + info "Creating temporary self-signed certificate …" + mkdir -p "$LIVE_DIR" + openssl req -x509 -nodes -newkey rsa:2048 -days 1 \ + -keyout "$LIVE_DIR/privkey.pem" \ + -out "$LIVE_DIR/fullchain.pem" \ + -subj "/CN=dociva.io" 2>/dev/null + ok "Temporary certificate created" +fi + +# ── Step 4: Start Nginx (uses the temp cert) ── +info "Starting Nginx …" +$COMPOSE up -d nginx +ok "Nginx is running" + +# ── Step 5: Remove the temporary certificate ── +info "Removing temporary certificate …" +rm -rf "$LIVE_DIR" +ok "Temporary certificate removed" + +# ── Step 6: Request real certificate from Let's Encrypt ── +info "Requesting Let's Encrypt certificate …" + +DOMAIN_ARGS="" +for d in "${DOMAINS[@]}"; do + DOMAIN_ARGS="$DOMAIN_ARGS -d $d" +done + +STAGING_ARG="" +if [ "$STAGING" -eq 1 ]; then + STAGING_ARG="--staging" +fi + +$COMPOSE run --rm certbot certonly --webroot \ + --webroot-path=/var/www/certbot \ + $DOMAIN_ARGS \ + --email "$EMAIL" \ + --agree-tos \ + --no-eff-email \ + --force-renewal \ + $STAGING_ARG + +ok "Certificate obtained successfully" + +# ── Step 7: Reload Nginx with the real certificate ── +info "Reloading Nginx …" +$COMPOSE exec nginx nginx -s reload +ok "Nginx reloaded with Let's Encrypt certificate" + +echo "" +ok "HTTPS is now active for ${DOMAINS[*]}" +echo " Test: curl -I https://dociva.io"