Can't upload files over 512MB using HA NC Backup to NC Docker image + Nginx Proxy Manager

Nextcloud version: 27.1.0
Operating system and version: Nextcloud Docker image (Debian)
Apache version: 2.4.57
PHP version: 8.2.10

The issue you are facing:
Can’t upload files larger than 512MB using the Home Assistant Nextcloud Backup Add-On. See

https://github.com/Sebclem/hassio-nextcloud-backup/issues/9

The error message is

Fail to upload snapshot to nextcloud (HTTPError: Response code 413 (Request Entity Too Large)) !

I have tried setting the following advanced settings in the Nginx Proxy Manager

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }

proxy_max_temp_file_size 10240;
fastcgi_request_buffering off;
proxy_request_buffering off;
proxy_buffering off;
client_max_body_size 0;

In the docker-compose.yaml of the Nextcloud image I have set the following, which is confirmed by the PHP Info in the UI that I had previously activated.

environment:
      - PHP_MEMORY_LIMIT=1G
      - PHP_UPLOAD_LIMIT=10G

I have tried setting the upload chunk size with

sudo -u www-data php occ config:app:set files max_chunk_size --value 20971520

and literally everything else in

https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html

The only setting I could not find is how to edit the Apache2 config in the Docker container, since I couldn’t find the config file.
The output of your Nextcloud log in Admin > Logging:
No log to see that fits the issue.

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  '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,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'redis',
    'password' => '',
    'port' => 6379,
  ),
  'instanceid' => 'id',
  'passwordsalt' => 'salt',
  'secret' => 'secret',
  'trusted_domains' => 
  array (
    0 => nextcloud.cloudprovider.org',
    1 => 'localhostname',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '27.1.0.7',
  'overwrite.cli.url' => 'https://nextcloud.cloudprovider.org',
  'overwriteprotocl' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'dbuser',
  'dbpassword' => 'password',
  'installed' => true,
  'default_phone_region' => 'DE',
  'overwriteprotocol' => 'https',
  'mail_from_address' => 'user',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'mail.com',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.web.de',
  'mail_smtpport' => '587',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => 'user',
  'mail_smtppassword' => 'password',
  'loglevel' => 2,
  'maintenance' => false,
);

The output of your Apache/nginx/system log in /var/log/____:
No logs here. Only symlinks to stdout and stderr

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{
  "reqId": "mmNzAjm3PLvBHZWDQffQ",
  "level": 3,
  "time": "2023-10-03T11:02:21+00:00",
  "remoteAddr": "149.224.255.27",
  "user": "jan",
  "app": "no app in context",
  "method": "PUT",
  "url": "/remote.php/webdav/Home%20Assistant%20Backup/Manual/Auto-2023.9.3-2023-10-01_0000.tar",
  "message": "Erwartete Dateigr\u00f6\u00dfe von 1613936640 bytes, aber 0 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.",
  "userAgent": "got (https://github.com/sindresorhus/got)",
  "version": "27.1.0.7",
  "exception": {
    "Exception": "Sabre\\DAV\\Exception\\BadRequest",
    "Message": "Erwartete Dateigr\u00f6\u00dfe von 1613936640 bytes, aber 0 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.",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php",
        "line": 149,
        "function": "put",
        "class": "OCA\\DAV\\Connector\\Sabre\\File",
        "type": "->",
        "args": ["*** sensitive parameters replaced ***"]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 1098,
        "function": "createFile",
        "class": "OCA\\DAV\\Connector\\Sabre\\Directory",
        "type": "->",
        "args": ["*** sensitive parameters replaced ***"]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
        "line": 504,
        "function": "createFile",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": ["*** sensitive parameters replaced ***"]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpPut",
        "class": "Sabre\\DAV\\CorePlugin",
        "type": "->",
        "args": [["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"]]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "method:PUT",
          [["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"]]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"]]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 321,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/apps/dav/appinfo/v1/webdav.php",
        "line": 85,
        "function": "exec",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/remote.php",
        "line": 172,
        "args": ["/var/www/html/apps/dav/appinfo/v1/webdav.php"],
        "function": "require_once"
      }
    ],
    "File": "/var/www/html/apps/dav/lib/Connector/Sabre/File.php",
    "Line": 297,
    "message": "Erwartete Dateigr\u00f6\u00dfe von 1613936640 bytes, aber 0 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.",
    "exception": {},
    "CustomMessage": "Erwartete Dateigr\u00f6\u00dfe von 1613936640 bytes, aber 0 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."
  }
}

You may be hitting a change Apache made in it’s default behavior. You can now (as of a two weeks ago) more easily override this in the community NC Docker image using APACHE_BODY_LIMIT. It’s documented at the end of the variables section in the README now too.

References:

https://github.com/nextcloud/docker/issues/1796

@jtr Yes, APACHE_BODY_LIMIT=0 did the trick. Thank you! :slight_smile:

1 Like

Hi, i just wanted to create account and say a HUGE THANKS to @jtr .
I updated my yml file in docker compose using APACHE_BODY_LIMIT=0 then 413 error went POOF :smiley:

I searched for 6hours straight until i found this thread.

1 Like