#!/bin/bash # Backup current Caddyfile sudo cp /etc/caddy/Caddyfile /etc/caddy/Caddyfile.backup.$(date +%Y%m%d_%H%M%S) # Create new docs.klas.chat configuration for Mintlify proxy cat > /tmp/docs_config << 'EOF' docs.klas.chat { tls /certs/klas.chat/fullchain.cer /certs/klas.chat/klas.chat.key # Basic Authentication basicauth * { langmem $2a$14$.1fx02QwkkmfezhZMLE4Iu2N/ub5vwDSAtcH9lAa5z11ChjiYy1PG } # Security headers header { X-Frame-Options "DENY" X-Content-Type-Options "nosniff" X-XSS-Protection "1; mode=block" Referrer-Policy "strict-origin-when-cross-origin" Strict-Transport-Security "max-age=31536000; includeSubDomains" Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net https://unpkg.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://unpkg.com; img-src 'self' data: https:; font-src 'self' data: https:; connect-src 'self' ws: wss:;" } # Proxy to Mintlify development server reverse_proxy localhost:3003 # Enable compression encode gzip } EOF # Replace the docs.klas.chat section in Caddyfile sudo sed -i '/^docs\.klas\.chat {/,/^}/c\ docs.klas.chat {\ tls /certs/klas.chat/fullchain.cer /certs/klas.chat/klas.chat.key\ \ # Basic Authentication\ basicauth * {\ langmem $2a$14$.1fx02QwkkmfezhZMLE4Iu2N\/ub5vwDSAtcH9lAa5z11ChjiYy1PG\ }\ \ # Security headers\ header {\ X-Frame-Options "DENY"\ X-Content-Type-Options "nosniff"\ X-XSS-Protection "1; mode=block"\ Referrer-Policy "strict-origin-when-cross-origin"\ Strict-Transport-Security "max-age=31536000; includeSubDomains"\ Content-Security-Policy "default-src '\''self'\''; script-src '\''self'\'' '\''unsafe-inline'\'' '\''unsafe-eval'\'' https://cdn.jsdelivr.net https://unpkg.com; style-src '\''self'\'' '\''unsafe-inline'\'' https://cdn.jsdelivr.net https://unpkg.com; img-src '\''self'\'' data: https:; font-src '\''self'\'' data: https:; connect-src '\''self'\'' ws: wss:;"\ }\ \ # Proxy to Mintlify development server\ reverse_proxy localhost:3003\ \ # Enable compression\ encode gzip\ }' /etc/caddy/Caddyfile echo "✅ Caddy configuration updated to proxy docs.klas.chat to localhost:3003" echo "🔄 Reloading Caddy configuration..." sudo systemctl reload caddy if [ $? -eq 0 ]; then echo "✅ Caddy reloaded successfully" echo "🌐 Documentation should now be available at: https://docs.klas.chat" else echo "❌ Failed to reload Caddy. Check configuration:" sudo caddy validate --config /etc/caddy/Caddyfile fi