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/):
- Open the Apache security configuration file:bash
nano /etc/apache2/conf-available/security.conf请谨慎使用此类代码。 - Locate line 53:apache
RedirectMatch 404 "/\." - Replace it with one of the following options:
- Option A (Recommended — Allows chunked uploads,
/.well-known/, and syncing dot-files like.gitignorevia WebDAV):apacheRedirectMatch 404 "^(?!/remote\.php/dav/|/\.well-known/).*/\."。 - Option B (Strict — Only allows the
/.filechunk merge endpoint and/.well-known/):apacheRedirectMatch 404 "^(?!/remote\.php/dav/uploads/.*/\.file$|/\.well-known/).*/\."。
- Option A (Recommended — Allows chunked uploads,
- Test the Apache configuration and reload the service:bash
apache2ctl configtest && systemctl reload apache2。
After reloading Apache2, uploads larger than 100 MB will assemble and complete normally.
留言