Even small files (>1MB) not uploading via Cloudflare Tunnel

Nextcloud version : 28.0.3
Operating system and version: Debian 12.2
Apache or nginx version: Apache 2.4.58
PHP version: 8.1.27

The issue you are facing:
Uploading files (even small ones) doesn’t finish when using cloudflare tunnel.

Is this the first time you’ve seen this error?: N

Steps to replicate it:

  1. Setup Nextcloud AIO in reverse proxy mode
  2. Connect cloudflare tunnel to nextcloud
  3. Sync a file >1MB with the desktop client
  4. Files <10MB even get uploaded until the end but they don’t fully finish. You can see the loading bar is filled but they seems to be some kind of verification step not working.
    Bildschirmfoto 2024-04-09 um 12.18.59
  5. Files >10MB just stop uploading somwhere between 10MB and 20MB
    Bildschirmfoto 2024-04-09 um 12.19.55

I really don’t understand whats going on here. I’ve read numerous posts about cloudflare interrupting uploads around 1GB but these files really are not that big.

The output of your Nextcloud log in Admin > Logging, in German, sorry:

[no app in context] Fehler: Erwartete Dateigröße von 5182389 bytes, aber 4128768 bytes gelesen (vom Nextcloud-Client) und geschrieben (in den Nextcloud-Speicher). Dies kann entweder ein Netzwerkproblem auf der sendenden Seite oder ein Problem beim Schreiben in den Speicher auf der Serverseite sein.
	PUT /remote.php/dav/files/<USER>/<DIR>/<FILE.mp4>
	von <PRIVATE_IP> von <USER> um <TIMESTAMP>

It says:
Expected files size of 5182389 bytes but only 4128768 bytes read (NC client) and written (NC storage). This is probably due to a network problem on the sender side or a problem with writing in the storage on the server side.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'one-click-instance' => true,
  'one-click-instance.user-limit' => 100,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'appsallowlist' => false,
  'check_data_directory_permissions' => false,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'nextcloud-aio-redis',
    'password' => '<*****>',
    'port' => 6379,
  ),
  'overwritehost' => '<NEXTCLOUD.DOMAIN>',
  'overwriteprotocol' => 'https',
  'passwordsalt' => '<*****>',
  'secret' => '<*****>',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '<NEXTCLOUD.DOMAIN>',
    2 => '<PRIVATE_IP>',
  ),
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '28.0.3.2',
  'overwrite.cli.url' => 'https://<NEXTCLOUD.DOMAIN>/',
  'dbname' => 'nextcloud_database',
  'dbhost' => 'nextcloud-aio-database',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_nextcloud',
  'dbpassword' => '<*****>',
  'installed' => true,
  'instanceid' => '<*****>',
  'maintenance' => false,
  'maintenance_window_start' => 1,
  'default_phone_region' => 'DE',
  'updatedirectory' => '/nc-updater',
  'loglevel' => '2',
  'app_install_overwrite' => 
  array (
    0 => 'nextcloud-aio',
    1 => 'twofactor_gateway',
  ),
  'log_type' => 'file',
  'logfile' => '/var/www/html/data/nextcloud.log',
  'log_rotate_size' => '10485760',
  'log.condition' => 
  array (
    'apps' => 
    array (
      0 => 'admin_audit',
    ),
  ),
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'enabledPreviewProviders' => 
  array (
    1 => 'OC\\Preview\\Image',
    2 => 'OC\\Preview\\MarkDown',
    3 => 'OC\\Preview\\MP3',
    4 => 'OC\\Preview\\TXT',
    5 => 'OC\\Preview\\OpenDocument',
    6 => 'OC\\Preview\\Movie',
    7 => 'OC\\Preview\\Krita',
    0 => 'OC\\Preview\\Imaginary',
  ),
  'enable_previews' => true,
  'upgrade.disable-web' => true,
  'mail_smtpmode' => 'smtp',
  'trashbin_retention_obligation' => 'auto, 30',
  'versions_retention_obligation' => 'auto, 30',
  'activity_expire_days' => '30',
  'simpleSignUpLink.shown' => false,
  'share_folder' => '/Shared',
  'one-click-instance.link' => 'https://nextcloud.com/all-in-one/',
  'upgrade.cli-upgrade-link' => 'https://github.com/nextcloud/all-in-one/discussions/2726',
  'allow_local_remote_servers' => true,
  'davstorage.request_timeout' => 3600,
  'htaccess.RewriteBase' => '/',
  'dbpersistent' => false,
  'files_external_allow_create_new_local' => false,
  'trusted_proxies' => 
  array (
    0 => '127.0.0.1',
    1 => '::1',
  ),
  'preview_imaginary_url' => 'http://nextcloud-aio-imaginary:9000',
);

The output of your Apache/nginx/system log in /var/log/____:
There are no log entries related to my incident. The only entry that comes up a few times a day is that one.

[<TIMESTAMP>] [error] [(70008)Partial results are valid but processing is incomplete] [client: <IPv6>, <IPv4>] [AH01075: Error dispatching request to : (reading input brigade)] [Mozilla/5.0 (Macintosh) mirall/3.12.3git (build 21830) (Nextcloud, osx-23.4.0 ClientArchitecture: arm64 OsArchitecture: arm64)]

I hope some of you already experienced this issue. Again: I know of the limitations of using a cloudflare tunnel, but I have no choice bc my Router is behind a stupid DS-Lite Tunnel. I read about problems with really big files but why do files ~5MB have problems?

Same problem here! I also have the problem with the DS-Lite tunnel.
I had a working solution before by renting a vserver, on which I had a service running (6tunnel) that forwards IPv4 requests to the current IPv6 Adress of my server. Then I learnt about cloudflare tunnels and canceled the vserver subscription. I experience the same problem now.

I get this error in the logs of the cloudflare tunnel

ERR Request failed error="Incoming request ended abruptly: context canceled" connIndex=0

In the nextcloud logs I get the same

BadRequest Erwartete Dateigröße von 32136500 bytes, aber 761856 bytes gelesen (vom Nextcloud-Client) und geschrieben (in den Nextcloud-Speicher) [...]

This may be related to http2 as other users experienced similar problems (Problem uploading files to NC18 - Expected filesize of 1024000 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 696024 bytes - #13 by j.koopmann). Unfortunately, Cloudflare’s free plan does not allow disabling http2.

I think I’ll revert to the vserver solution with my own reverse proxy