Problem Description

When running Nextcloud inside a TurnKey Linux LXC container (based on Debian 13 / Trixie with Apache2), uploading files larger than 100 MB via the Web UI or WebDAV clients fails, while files ≤ 100 MB upload normally.

Inspecting the Apache2 access logs reveals that the individual chunks upload successfully (PUT ... -> 201), but the final assembly request fails with an Apache 404 Not Found error:

MKCOL  /remote.php/dav/uploads/<user>/web-file-upload-xxxx       -> 201
PUT    /remote.php/dav/uploads/<user>/web-file-upload-xxxx/1     -> 201
PUT    /remote.php/dav/uploads/<user>/web-file-upload-xxxx/2     -> 201
MOVE   /remote.php/dav/uploads/<user>/web-file-upload-xxxx/.file -> 404
DELETE /remote.php/dav/uploads/<user>/web-file-upload-xxxx       -> 204

Root Cause

By default, Nextcloud splits uploads larger than 100 MB into chunks (files.chunked_upload.max_size) and merges them at the end using a WebDAV MOVE request targeting a virtual path ending in /.file.

However, the TurnKey Linux Apache2 configuration includes a global security rule in /etc/apache2/conf-available/security.conf (line 53) designed to block access to hidden files and directories (such as .git or .svn):

apache

RedirectMatch 404 "/\."

Because RedirectMatch (mod_alias) executes very early in the Apache request lifecycle (before mod_rewrite or PHP receives the request), any URI containing /.—including Nextcloud’s /.file merge endpoint—is immediately intercepted and rejected with a default Apache 404 page.

Solution / Workaround

To fix this without disabling hidden-file protection across the rest of your server, update the regex in /etc/apache2/conf-available/security.conf using a negative lookahead to exclude Nextcloud’s WebDAV endpoints (and /.well-known/):

  1. Open the Apache security configuration file:bashnano /etc/apache2/conf-available/security.conf 请谨慎使用此类代码。
  2. Locate line 53:apacheRedirectMatch 404 "/\."
  3. Replace it with one of the following options:
    • Option A (Recommended — Allows chunked uploads, /.well-known/, and syncing dot-files like .gitignore via WebDAV):apacheRedirectMatch 404 "^(?!/remote\.php/dav/|/\.well-known/).*/\." 。
    • Option B (Strict — Only allows the /.file chunk merge endpoint and /.well-known/):apacheRedirectMatch 404 "^(?!/remote\.php/dav/uploads/.*/\.file$|/\.well-known/).*/\." 。
  4. Test the Apache configuration and reload the service:bashapache2ctl configtest && systemctl reload apache2 。

After reloading Apache2, uploads larger than 100 MB will assemble and complete normally.

最后修改日期: 2026年11月27日

作者

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。