# DSS Admin UI - Production Deployment Guide ## ๐ŸŽฏ Expert Analysis Summary (Gemini 3 Pro) **Root Cause**: Public URL https://dss.overbits.luz.uy/admin-ui/index.html returns 401 because: - Nginx is configured to proxy to Vite dev server (localhost:3456) which is development-only - No production build is being served - Basic Auth is enabled (expected) **Solution**: Configure nginx to serve static files directly and proxy API requests to FastAPI backend. ## โœ… Completed Steps 1. **Production Build**: โœ… `npm run build` completed - Output: `/home/overbits/dss/admin-ui/dist/` - Console forwarder copied to dist directory 2. **Vite Dev Server**: โœ… Stopped (not needed for production) 3. **FastAPI Backend**: โœ… Running on localhost:8002 (PID 4177150) - Endpoint `/api/logs/browser` verified and working 4. **Nginx Config**: โœ… Created at `.dss/nginx-config-dss.overbits.luz.uy.conf` ## ๐Ÿ”ง Manual Steps Required (Requires sudo) ### Step 1: Backup Current Nginx Config ```bash sudo cp /etc/nginx/sites-available/dss.overbits.luz.uy.conf /etc/nginx/sites-available/dss.overbits.luz.uy.conf.backup-$(date +%Y%m%d) ``` ### Step 2: Apply New Nginx Configuration ```bash sudo cp /home/overbits/dss/.dss/nginx-config-dss.overbits.luz.uy.conf /etc/nginx/sites-available/dss.overbits.luz.uy.conf ``` ### Step 3: Test Nginx Configuration ```bash sudo nginx -t ``` Expected output: `nginx: configuration file /etc/nginx/nginx.conf test is successful` ### Step 4: Restart Nginx ```bash sudo systemctl reload nginx # OR sudo systemctl restart nginx ``` ### Step 5: Verify Services ```bash # Check FastAPI is running curl -s http://localhost:8002/docs | head -10 # Check nginx is serving static files curl -k -s https://dss.overbits.luz.uy/ -u username:password | head -20 ``` ## ๐Ÿ“‹ Key Configuration Changes ### Before (Development) ```nginx location / { proxy_pass http://127.0.0.1:3456; # Vite dev server ... } ``` ### After (Production) ```nginx root /home/overbits/dss/admin-ui/dist; index index.html; location /api/ { proxy_pass http://127.0.0.1:8002; # FastAPI backend ... } location / { try_files $uri $uri/ /index.html; # Serve static files } ``` ## ๐Ÿ” Service Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ https://dss.overbits.luz.uy โ”‚ โ”‚ (Public URL with Basic Auth) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ” โ”‚ Nginx โ”‚ โ”‚ (Port 443)โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”‚ Static โ”‚ โ”‚ API โ”‚ โ”‚ Files โ”‚ โ”‚ Proxy โ”‚ โ”‚ /dist/ โ”‚ โ”‚ /api/ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”‚ FastAPI โ”‚ โ”‚ :8002 โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ## ๐ŸŽฏ Port Allocation (Final) | Service | Port | Status | Purpose | |---------|------|--------|---------| | Nginx | 443 | โœ… Running | Public HTTPS endpoint | | FastAPI | 8002 | โœ… Running | API backend + browser logging | | Orchestrator | 8000 | โœ… Running | MCP server (unchanged) | | Storybook | 6006 | โœ… Running | Design system docs | | ~~Vite Dev~~ | ~~3456~~ | โŒ Stopped | No longer needed | ## ๐Ÿ” Browser Logging in Production The browser console logging system will work automatically because: 1. **Console Forwarder**: Loaded in index.html (first script) 2. **API Endpoint**: `/api/logs/browser` proxied through nginx 3. **Authentication**: Inherits browser's authenticated session 4. **CORS**: Resolved by proxying through same domain Logs will be written to: `.dss/logs/browser-logs/browser.log` ## ๐Ÿงช Testing Checklist After applying the nginx config: 1. โœ… **Access public URL**: https://dss.overbits.luz.uy/ - Should show admin UI (after Basic Auth) - No more 401 errors 2. โœ… **Check browser console**: Open DevTools - Should see: `[Console Forwarder] Initialized. Monitoring active.` 3. โœ… **Verify browser logging**: ```bash # Trigger some console logs in browser # Then check server logs: ./admin-ui/scripts/dss-logs.sh ``` 4. โœ… **Test API endpoint** (from browser DevTools console): ```javascript fetch('/api/logs/browser', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ logs: [{level: 'info', timestamp: new Date().toISOString(), message: 'Test', data: []}] }) }).then(r => r.json()).then(console.log); ``` ## ๐Ÿšจ Troubleshooting ### Issue: 502 Bad Gateway - **Cause**: FastAPI backend not running - **Fix**: `cd tools/api && python3 -m uvicorn server:app --host 127.0.0.1 --port 8002 &` ### Issue: 403 Forbidden - **Cause**: Nginx can't read dist directory - **Fix**: `chmod -R 755 /home/overbits/dss/admin-ui/dist` ### Issue: Console forwarder not loaded - **Cause**: File not in dist directory - **Fix**: Already copied, but verify: ```bash ls -la /home/overbits/dss/admin-ui/dist/admin-ui/js/utils/console-forwarder.js ``` ### Issue: API requests fail in browser - **Cause**: Nginx not proxying /api - **Fix**: Verify nginx config has `/api/` location block ## ๐Ÿ“Š Current Status - โœ… Production build ready - โœ… FastAPI backend running - โœ… Console forwarder integrated - โœ… Nginx config prepared - โณ **Awaiting**: Apply nginx config with sudo - โณ **Awaiting**: Test public URL ## ๐Ÿ“ Next Steps for User **YOU NEED TO:** 1. Run the 4 commands in "Manual Steps Required" (requires sudo) 2. Test the public URL: https://dss.overbits.luz.uy/ 3. Verify browser logging is working 4. Confirm all services accessible **Estimated time**: 5 minutes