Skip to main contentSkip to main content
Andrés Morales

Linux VPS Hardening, Caddy HTTP/3, and Automated Encrypted Telegram Backups for Automation Pipelines

AM

Andrés Morales

AI & Full-Stack Systems Architect

•2 min
#DevOps#Linux#Security#Caddy#Automation#NextJS

As a Senior Full-Stack & AI Automation Engineer, shipping features is only half the battle. If underlying infrastructure lacks determinism, resilience, and solid hardening, mission-critical pipelines will inevitably break under load.

Today in the studio, our focus shifted toward consolidating multi-repository architectures, technical reviews for studio briefs, and executing systematic server hardening across our Linux production VPS.

Desktop architecture and metrics view


1. Today's Challenge: Deterministic Perimeter Defense and Zero-Cost Backups

Our AI pipelines and web systems demand low-maintenance high availability:

  1. Strict perimeter isolation by dropping all non-essential inbound ports.
  2. Active intrusion prevention targeting SSH and Docker authentication endpoints.
  3. Serving traffic with ultra-low latency through HTTP/3 (QUIC) and TLS 1.3 without manual certificate overhead.
  4. Off-host database snapshots stored automatically in a secure, accessible vault.

Mobile metrics view


2. Infrastructure & Hardening Architecture

Our production setup leverages three defense layers:

  • Network Perimeter (UFW): Strict drop policy (DEFAULT_INPUT_POLICY="DROP"), exposing only port 22 (SSH secured by Ed25519 keys), 80 (HTTP redirect), and 443 (HTTPS/UDP for QUIC).
  • Intrusion Prevention (Fail2ban): Active jails for sshd and docker-auth featuring exponential ban intervals.
  • Edge Reverse Proxy (Caddy Server): Native QUIC / HTTP/3 support and automated certificate lifecycle management via Let's Encrypt.
flowchart TD
    Client([External Traffic]) -->|QUIC / HTTP/3 - Port 443| UFW[UFW Firewall - Strict Drop]
    UFW --> Caddy[Caddy Edge Proxy - Auto TLS 1.3]
    Caddy --> App[Next.js App / AI Pipelines]
    
    F2B[Fail2ban Jails: sshd & docker-auth] -.->|Inspect & Ban| UFW
    
    Cron[Daily Scheduled Cron] -->|pg_dump streaming| BackupScript[Encrypted Snapshot Script]
    BackupScript -->|Telegram Bot HTTPS API| TelegramVault[(Private Telegram Vault)]

3. Automated Telegram Database Vault Backup

Instead of provisioning bloated storage pipelines for rapid daily rollbacks, we deployed a lightweight streaming bash pipeline dispatching snapshots to a dedicated private Telegram vault:

#!/usr/bin/env bash
set -euo pipefail

TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
BACKUP_DIR="/var/backups/db"
FILENAME="db_snapshot_${TIMESTAMP}.sql.gz"
FILEPATH="${BACKUP_DIR}/${FILENAME}"

mkdir -p "${BACKUP_DIR}"

# Compressed stream snapshot
docker exec -t production-postgres-1 pg_dump -U "$DB_USER" "$DB_NAME" | gzip -9 > "${FILEPATH}"

# Ship to private Telegram vault
curl -s -F chat_id="${TELEGRAM_BACKUP_CHAT_ID}" \
     -F document=@"${FILEPATH}" \
     -F caption="🔒 Production DB Snapshot - ${TIMESTAMP}" \
     "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendDocument" > /dev/null

# Local cleanup (3-day rolling retention)
find "${BACKUP_DIR}" -type f -name "*.sql.gz" -mtime +3 -delete

4. Operational ROI and Reliability

Engineering efficiency comes from automating defensive posture and backup routines once, allowing total focus on core product architecture.

ROI Component

Looking to build scalable, automated, and hardened infrastructure for your digital products? Let's connect at andresmorales.com.co.

CONSULTING & ARCHITECTURE

Need to automate your business operations or ship high-velocity web products?

I architect AI pipelines, modernize stacks with Next.js, and harden Linux infrastructure. Let’s talk architecture, scalability, and measurable ROI.

AI Automation · UI/UX · Production

Ship the thing.Skip the boilerplate.

Independent practice based in Cali. Automation flows, hand-built UI, and end-to-end web — for teams that would rather have it done than debate it.

Let's talk
2,014Est. 2014

From intake to deploy, the studio keeps work in one place: scope, design, build, ship. Briefs land on the desk, deliverables land on the client.

Andrés Morales