server { listen 80; server_name localhost; # 增加客户端请求体大小限制 client_max_body_size 20M; location / { root /usr/share/nginx/html; try_files $uri /index.html; } location /api/ { proxy_pass http://api:5050/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_set_header Connection ''; proxy_http_version 1.1; # SSE/流式响应支持 proxy_buffering off; proxy_cache off; chunked_transfer_encoding on; # 增加超时时间(上传和流式响应) proxy_read_timeout 600; proxy_connect_timeout 600; proxy_send_timeout 600; } }