Nextcloud 21 ios upload hangs on large files, getting nginx and nextcloud errors

Nextcloud version (eg, 20.0.5): 21.0.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.2 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache 2.25
PHP version (eg, 7.4): 7.4

The issue you are facing:

Not able to upload large files ~3.5 - 4 GB, when uploading IOS app, the file simply hangs. I am using Nginx Proxy Manager on a separate machine to route the traffic to nextcloud. I have posted the Proxy Host config for nextcloud as well as the nginx logs.

All files uploaded via IOS app that are under ~1.2 GB are uploaded without any issues, however is the size goes above that say to ~1.5 GB it errors a few times then finally uploads when you leave the phone on.

This nextcloud server is running in a Virtualbox Virtual Machine with the Host system as windows 10 and guest as Ubuntu server 20.04.2 LTS.

Any help will be appreciated, I set this up on my grandparents phones as well so that their camera roll can be automatically backed up and then viewable on the tv via plex. However the uploads get stuck once the app hits a large file.

Ini file /etc/php/7.4/apache2/php.ini :

engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
disable_classes =
zend.enable_gc = On
zend.exception_ignore_args = On
expose_php = Off
max_execution_time = 3600
max_input_time = 3600
memory_limit = 8G
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 16G
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 16G
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
cli_server.color = On
date.timezone = "America/Los_Angeles"
pdo_mysql.default_socket=
SMTP = localhost
mail.add_x_header = Off
smtp_port = 25
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
bcmath.scale = 0
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.cookie_samesite =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
zend.assertions = -1
tidy.clean_output = Off
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
ldap.max_links = -1
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=1
opcache.save_comments=1

Nginx Proxy host config

# ------------------------------------------------------------
# cloud.nextcloud.com
# ------------------------------------------------------------

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php/php7.4-fpm.sock;
}

server {
  set $forward_scheme http;
  set $server         "xxx.xxx.x.xxx";
  set $port           80;

  server_name cloud.nextcloud.com;

  listen 80;
  listen [::]:80;

  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-3/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-3/privkey.pem;


  # set max upload size
  client_max_body_size 1024M;
  fastcgi_buffers 64 8K;
  fastcgi_connect_timeout 60;
  fastcgi_send_timeout 1800;
  fastcgi_read_timeout 1800;

  # Enable gzip but do not remove ETag headers
  gzip on;
  gzip_vary on;
  gzip_comp_level 4;
  gzip_min_length 256;
  gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

  # HTTP response headers borrowed from Nextcloud `.htaccess`
  add_header Referrer-Policy                      "no-referrer"   always;
  add_header X-Content-Type-Options               "nosniff"       always;
  add_header X-Download-Options                   "noopen"        always;
  add_header X-Frame-Options                      "SAMEORIGIN"    always;
  add_header X-Permitted-Cross-Domain-Policies    "none"          always;
  add_header X-Robots-Tag                         "none"          always;
  add_header X-XSS-Protection                     "1; mode=block" always;


  # Remove X-Powered-By, which is an information leak
  fastcgi_hide_header X-Powered-By;

  # Path to the root of your installation
  root $scheme://$host:$server_port/var/www/nextcloud;


    # Make a regex exception for `/.well-known` so that clients can still
    # access it despite the existence of the regex rule
    # `location ~ /(\.|autotest|...)` which would otherwise handle requests
    # for `/.well-known`.
    location ^~ /.well-known {
        # The following 6 rules are borrowed from `.htaccess`

        location = /.well-known/carddav     { return 301 /remote.php/dav/; }
        location = /.well-known/caldav      { return 301 /remote.php/dav/; }
        # Anything else is dynamically handled by Nextcloud
        location ^~ /.well-known            { return 301 /index.php$uri; }

        try_files $uri $uri/ =404;
    }

  # Asset Caching
  include conf.d/include/assets.conf;


  # Block Exploits
  include conf.d/include/block-exploits.conf;

  # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
  add_header Strict-Transport-Security "max-age=63072000; preload" always;

  access_log /data/logs/proxy_host-5.log proxy;

  location / {

    # Force SSL
    include conf.d/include/force-ssl.conf;

    # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
    add_header Strict-Transport-Security "max-age=63072000; preload" always;

    # Proxy!
    include conf.d/include/proxy.conf;

  }

  # Custom
  include /data/nginx/custom/server_proxy[.]conf;

}

The following are the NGINX logs after trying to upload a ~3.5 GB Video file:

[23/Mar/2021:10:23:58 +0000] - 200 200 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/user_status>
[23/Mar/2021:10:24:01 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:24:07 +0000] - 207 207 - PROPFIND https cloud.nextcloud.com "/remote.php/webdav" [Cl>
[23/Mar/2021:10:24:07 +0000] - 207 207 - PROPFIND https cloud.nextcloud.com "/remote.php/webdav/" [C>
[23/Mar/2021:10:24:11 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:24:11 +0000] - 204 204 - PUT https cloud.nextcloud.com "/apps/user_status/heartbeat">
[23/Mar/2021:10:24:12 +0000] - 200 200 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/user_status>
[23/Mar/2021:10:24:13 +0000] - 304 304 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/notificatio>
[23/Mar/2021:10:24:16 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:24:21 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:24:31 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:24:36 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:24:41 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:24:44 +0000] - 304 304 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/notificatio>
[23/Mar/2021:10:24:51 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:24:57 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:25:01 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:25:11 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:25:14 +0000] - 304 304 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/notificatio>
[23/Mar/2021:10:25:17 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:25:21 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:25:31 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:25:37 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:25:41 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:25:44 +0000] - 304 304 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/notificatio>
[23/Mar/2021:10:25:51 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:25:58 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:26:02 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:26:12 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:26:14 +0000] - 304 304 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/notificatio>
[23/Mar/2021:10:26:14 +0000] - 204 204 - PUT https cloud.nextcloud.com "/apps/user_status/heartbeat">
[23/Mar/2021:10:26:14 +0000] - 200 200 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/user_status>
[23/Mar/2021:10:26:18 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:26:22 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:26:22 +0000] - 204 204 - PUT https cloud.nextcloud.com "/apps/user_status/heartbeat">
[23/Mar/2021:10:26:22 +0000] - 204 204 - PUT https cloud.nextcloud.com "/apps/user_status/heartbeat">
[23/Mar/2021:10:26:22 +0000] - 200 200 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/user_status>
[23/Mar/2021:10:26:22 +0000] - 200 200 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/user_status>
[23/Mar/2021:10:26:32 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:26:38 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>
[23/Mar/2021:10:26:42 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:26:44 +0000] - 304 304 - GET https cloud.nextcloud.com "/ocs/v2.php/apps/notificatio>
[23/Mar/2021:10:26:52 +0000] - - 413 - PUT https cloud.nextcloud.com "/remote.php/webdav/20-12-25%20>
[23/Mar/2021:10:26:59 +0000] - 200 200 - GET https cloud.nextcloud.com "/apps/logreader/poll?lastReq>

Nextcloud config file:

<?php
$CONFIG = array (
  'instanceid' => '<instanceId>',
  'passwordsalt' => '<passwd>',
  'secret' => '<hash value>',
  'trusted_domains' =>
  array (
    0 => 'cloud.nextcloud.com',
    1 => 'xxx.xxx.x.xxx',
  ),
  'datadirectory' => '/home/usr/data',
  'dbtype' => 'mysql',
  'version' => '21.0.0.18',
  'overwrite.cli.url' => 'https://cloud.nextcloud.com',
  'overwriteprotocol' => 'https',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'password',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'redis' =>
    array (
      'host' => 'localhost',
      'port' => 0,
      'timeout' => 0.0,
    ),
  'default_phone_region' => 'ISO 3166-2:US',
);

Nextcloud Log:

{
  "reqId": "SSOpe0HsKr3CfLMW9gcy",
  "level": 3,
  "time": "2021-03-23T10:04:04+00:00",
  "remoteAddr": "192.168.1.98",     //Nginx server address
  "user": "<username>",
  "app": "no app in context",
  "method": "PUT",
  "url": "/remote.php/webdav/20-12-25%2016-51-31%208560.mov",
  "message": {
    "Exception": "Sabre\\DAV\\Exception\\BadRequest",
    "Message": "Expected filesize of 3871481530 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 523989928 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php",
        "line": 156,
        "function": "put",
        "class": "OCA\\DAV\\Connector\\Sabre\\File",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 1098,
        "function": "createFile",
        "class": "OCA\\DAV\\Connector\\Sabre\\Directory",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
        "line": 504,
        "function": "createFile",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpPut",
        "class": "Sabre\\DAV\\CorePlugin",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 321,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/dav/appinfo/v1/webdav.php",
        "line": 84,
        "function": "exec",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/remote.php",
        "line": 167,
        "args": ["/var/www/nextcloud/apps/dav/appinfo/v1/webdav.php"],
        "function": "require_once"
      }
    ],
    "File": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
    "Line": 246,
    "CustomMessage": "--"
  },
  "userAgent": "Mozilla/5.0 (iOS) Nextcloud-iOS/3.3.1",
  "version": "21.0.0.18",
  "id": "6059c0f807810"
}