worker_processes 1; events { worker_connections 1024; } http { access_log off; upstream fastapi_upstream { server 127.0.0.1:8000; } upstream streamlit_upstream { server 127.0.0.1:8501; } server { listen 7860; # /api/* -> FastAPI (BUT /api prefix is removed before forwarding) location /api/ { proxy_pass http://fastapi_upstream/; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; } # /admin/* -> Streamlit location /admin/ { proxy_pass http://streamlit_upstream/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; } # root -> admin (because humans love buttons more than endpoints 😄) location = / { return 302 /admin/; } } }