server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Serve static files, fallback to index.html for SPA routing location / { try_files $uri $uri/ /index.html; } # Proxy API requests to backend server location /api/ { proxy_pass http://server:3001/api/; 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 WebSocket for browser clients location /ws { proxy_pass http://server:3001/ws; 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_read_timeout 86400s; proxy_send_timeout 86400s; } # Proxy WebSocket for bridge clients location /ws/bridge { proxy_pass http://server:3001/ws/bridge; 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_read_timeout 86400s; proxy_send_timeout 86400s; } }