#!/bin/bash # Setup nginx reverse proxy for StemeDB dashboard set -e echo "Setting up nginx proxy for StemeDB..." # Create nginx config sudo tee /etc/nginx/sites-available/stemedb > /dev/null <<'EOF' server { listen 80; server_name jml; # Dashboard (Next.js) location / { proxy_pass http://127.0.0.1:18188; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_cache_bypass $http_upgrade; } # API endpoints location /v1/ { proxy_pass http://127.0.0.1:18180; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # Health endpoint location /health { proxy_pass http://127.0.0.1:18180; proxy_http_version 1.1; } # Metrics endpoint location /metrics { proxy_pass http://127.0.0.1:18180; proxy_http_version 1.1; } # Swagger UI location /swagger-ui { proxy_pass http://127.0.0.1:18180; proxy_http_version 1.1; } location /api-docs { proxy_pass http://127.0.0.1:18180; proxy_http_version 1.1; } } EOF # Enable site sudo ln -sf /etc/nginx/sites-available/stemedb /etc/nginx/sites-enabled/stemedb # Test nginx config echo "Testing nginx configuration..." sudo nginx -t # Reload nginx echo "Reloading nginx..." sudo systemctl reload nginx echo "✅ Nginx proxy configured!" echo "" echo "Setup complete. Now run:" echo " 1. cargo run --bin stemedb-api # Terminal 1" echo " 2. cd applications/stemedb-dashboard && npm run dev # Terminal 2" echo " 3. Open http://jml in your browser"