From 17a99e851825d858a32a86ce88168091b585c1f4 Mon Sep 17 00:00:00 2001 From: ilia Date: Wed, 25 Mar 2026 11:18:57 -0400 Subject: [PATCH] Add deploy docs: nginx vhost, Caddy, full deploy steps Made-with: Cursor --- deploy/DEPLOY.md | 100 +++++++++++++++++++++++ deploy/nginx-iliadobkin.com.conf.example | 29 +++++++ 2 files changed, 129 insertions(+) create mode 100644 deploy/DEPLOY.md create mode 100644 deploy/nginx-iliadobkin.com.conf.example diff --git a/deploy/DEPLOY.md b/deploy/DEPLOY.md new file mode 100644 index 0000000..810d6da --- /dev/null +++ b/deploy/DEPLOY.md @@ -0,0 +1,100 @@ +# Deploying iliadobkin.com + +## Architecture + +``` +Browser → Caddy (public IP, TLS) → nginx on 10.0.10.124:80 → /var/www/iliadobkin.com +``` + +- **DNS** for `iliadobkin.com` points to the **Caddy** server. +- **Caddy** terminates TLS and reverse-proxies to `10.0.10.124:80`. +- **nginx** on `10.0.10.124` (`portfolio`) serves static files from `/var/www/iliadobkin.com`. + +### Paths on `portfolio` (10.0.10.124) + +| Path | Purpose | +|------|---------| +| `/var/www/iliadobkin.com-src` | Git clone — pull, build here | +| `/var/www/iliadobkin.com` | Live site — nginx `root`, rsync `dist/` here | +| `/var/www/html` | Default nginx docroot — **not used** for this site | + +## Full deploy (SSH into `portfolio` as root) + +```bash +cd /var/www/iliadobkin.com-src +git fetch origin && git checkout main && git reset --hard origin/main +rm -rf node_modules dist +npm ci +npm run build +rsync -av --delete ./dist/ /var/www/iliadobkin.com/ +``` + +No nginx reload needed after a normal deploy — only the static files change. + +## Verify deploy worked + +```bash +# On the server — disk should match the build: +grep -o 'assets/index-[^"]*\.js' /var/www/iliadobkin.com/index.html + +# From anywhere — public site should match disk: +curl -sS https://iliadobkin.com/index.html | grep -o 'assets/index-[^"]*\.js' +``` + +Both commands must print the **same** hash (e.g. `assets/index-BURprqoD.js`). + +## If the site still looks old in the browser + +1. Hard refresh: **Ctrl+Shift+R** or open in a private/incognito window. +2. DevTools → **Application** → **Storage** → **Clear site data**, then reload. +3. The app is a PWA — an old service worker can cache stale assets. + +## nginx vhost (one-time setup) + +If `/etc/nginx/sites-available/iliadobkin.com` doesn't exist or nginx is serving +from `/var/www/html` instead, create the vhost: + +```bash +cat > /etc/nginx/sites-available/iliadobkin.com << 'EOF' +server { + listen 80; + listen [::]:80; + server_name iliadobkin.com www.iliadobkin.com; + + root /var/www/iliadobkin.com; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + + location /assets/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + } +} +EOF +ln -sf /etc/nginx/sites-available/iliadobkin.com /etc/nginx/sites-enabled/ +nginx -t && systemctl reload nginx +``` + +## Caddy config (on the Caddy server, not `portfolio`) + +```caddy +iliadobkin.com { + reverse_proxy 10.0.10.124:80 +} + +www.iliadobkin.com { + redir https://iliadobkin.com{uri} permanent +} +``` + +## Quick one-liner deploy + +```bash +ssh root@10.0.10.124 'cd /var/www/iliadobkin.com-src && git fetch origin && git reset --hard origin/main && rm -rf node_modules dist && npm ci && npm run build && rsync -av --delete ./dist/ /var/www/iliadobkin.com/' +``` diff --git a/deploy/nginx-iliadobkin.com.conf.example b/deploy/nginx-iliadobkin.com.conf.example new file mode 100644 index 0000000..c322420 --- /dev/null +++ b/deploy/nginx-iliadobkin.com.conf.example @@ -0,0 +1,29 @@ +# Install on the origin server (e.g. 10.0.10.124): +# sudo cp deploy/nginx-iliadobkin.com.conf.example /etc/nginx/sites-available/iliadobkin.com +# sudo ln -sf /etc/nginx/sites-available/iliadobkin.com /etc/nginx/sites-enabled/ +# sudo nginx -t && sudo systemctl reload nginx +# +# Caddy in front should reverse_proxy to this host :80 (unchanged). + +server { + listen 80; + listen [::]:80; + server_name iliadobkin.com www.iliadobkin.com; + + root /var/www/iliadobkin.com; + index index.html; + + # SPA: client-side routes fall back to index.html + location / { + try_files $uri $uri/ /index.html; + } + + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + + # Optional: long cache for hashed assets (browser renames on each build) + location /assets/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + } +}