worker_processes auto; pid /tmp/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; # Temp paths writable without root client_body_temp_path /tmp/client_body; proxy_temp_path /tmp/proxy; fastcgi_temp_path /tmp/fastcgi; uwsgi_temp_path /tmp/uwsgi; scgi_temp_path /tmp/scgi; sendfile on; tcp_nopush on; keepalive_timeout 65; # Increase timeouts for long-running pipeline (~5 min max) proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; # Larger buffers for clinical reports proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 7860; server_name _; # ── WebSocket: /ws/* → FastAPI backend ────────────────── location /ws/ { proxy_pass http://127.0.0.1:8002; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $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_read_timeout 600s; proxy_send_timeout 600s; } # ── REST API: /api/* → FastAPI backend ────────────────── location /api/ { proxy_pass http://127.0.0.1:8002; 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; } # ── Everything else → Next.js frontend ───────────────── location / { proxy_pass http://127.0.0.1:3000; 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; } # ── Next.js static assets ────────────────────────────── location /_next/ { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; } } }