You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx反向代理上传大文件失败问题求助

Troubleshooting Large File Upload Failures with Nginx Reverse Proxy to Synology Photos

Let's break down the possible issues and actionable fixes since you've already covered the basic client-side body size and timeout settings. Here's what to check next:

1. Ensure client_max_body_size applies to the right scope

You set client_max_body_size 0; in your main nginx.conf, but Nginx lets this parameter be overridden in server or location blocks. Double-check your site-specific config (usually in /etc/nginx/sites-available/ or /etc/nginx/conf.d/) for your photo.domain.com server block:

  • Add client_max_body_size 0; explicitly inside the server block or the specific location block that handles the proxy pass to Synology Photos.
  • Make sure no nested configs are setting a smaller value (like 10M) that would override the global setting.

2. Add proxy-side timeouts (you're missing these critical settings!)

Your current timeout rules only apply to client-Nginx connections, but you need to set timeouts for the Nginx-Synology NAS connection too. Drop these parameters inside your proxy location block:

proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;

Large file uploads take time to transfer from Nginx to the Synology, so these values need to be long enough to match your upload speed and file size.

3. Check Synology NAS's internal restrictions

Even local uploads work, Synology's own web server (it runs Nginx under the hood) might have limits that trigger when traffic comes through a reverse proxy:

  • Open Synology's Control Panel > Application Portal > Reverse Proxy and verify there are no additional body size limits set for your Photos entry.
  • Navigate to Synology Photos > Settings > Advanced to confirm the app itself has no global upload size restriction.
  • You can also spot-check Synology's internal Nginx configs (in /usr/syno/etc/nginx/conf.d/) to ensure client_max_body_size is set appropriately there (though local uploads working makes this less likely, it's worth a quick check).

4. Use Nginx error logs to pinpoint the exact issue

This is the most important step. When a large upload fails, check your Nginx error log (typically /var/log/nginx/error.log) for entries around the failure time:

  • 413 Request Entity Too Large: Confirms client_max_body_size is still not applied correctly.
  • upstream timed out: Means the proxy_read_timeout or Synology's side is timing out mid-transfer.
  • Connection reset errors: Points to a firewall or network device dropping the connection unexpectedly.

5. Rule out network/firewall limitations

If logs show unexpected connection drops, check:

  • Your router or firewall (both local and cloud-based, like Cloudflare if you use it) for upload file size or connection duration limits.
  • Ensure no traffic shaping or QoS rules are throttling large uploads through the reverse proxy.

6. Test incrementally to narrow down the problem

  • Start with a file size just above what works, then gradually increase it to find the exact threshold where failures start.
  • Temporarily set all timeout values to a very high number (e.g., 1800s = 30 minutes) to rule out timeout-related issues entirely, then adjust back to a reasonable value once it works.

内容的提问来源于stack exchange,提问作者Dan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 03:52:50