How to upload file larger than 10MB with nginx?

Nextcloud version : 18.0.3-1
Operating system and version: Arch Linux
nginx version: nginx/1.16.1
PHP version :PHP 7.4.4

The issue you are facing:
When Uploading file via the nextcloud client syncing fails and it is not possible to upload

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Install nextcloud client
  2. cp file >80 MB to nextcloud destination

The output of your Nextcloud log in Admin > Logging:

no nextcloud logs refering to this issue 

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

<?php
$CONFIG = array (
  'instanceid' => 'ocl1',
  'passwordsalt' => '9qKIB2',
  'secret' => '2A4a',
  'trusted_domains' => 
  array (
    0 => 'mycloud',
  ),
  'datadirectory' => '/media/hdd1',
  'dbtype' => 'mysql',
  'version' => '18.0.3.0',
  'overwrite.cli.url' => 'https://mycloud.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextclouduser',
  'dbpassword' => 'password',
  'installed' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____:

 12 Mar 31 11:49:50 alarmpi nginx[338]: 2020/03/31 11:49:50 [crit] 338#338: *18 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while sending to client, client: 7, ser    ver: , request: "PUT /remote.php/dav/uploads//2596988781/00000001 HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.sock", host: ""
 13 Mar 31 11:49:51 alarmpi nginx[338]: 2020/03/31 11:49:51 [crit] 338#338: *21 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while sending to client, client: 7, ser    ver: , request: "PUT /remote.php/dav/uploads//2596988781/00000001 HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.sock", host: ""
 14 Mar 31 11:51:54 alarmpi nginx[338]: 2020/03/31 11:51:54 [crit] 338#338: *35 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while keepalive, client: , server: 0.0.    0.0:443
 15 Mar 31 11:51:55 alarmpi nginx[338]: 2020/03/31 11:51:55 [crit] 338#338: *38 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while keepalive, client: , server: 0.0.    0.0:443
 16 Mar 31 11:52:11 alarmpi nginx[338]: 2020/03/31 11:52:11 [crit] 338#338: *49 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while waiting for request00.118.12, ser    ver: 0.0.0.0:443
 17 Mar 31 11:52:15 alarmpi nginx[338]: 2020/03/31 11:52:15 [crit] 338#338: *48 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while keepalive, client:  server: 0.0.0    .0:443
 18 Mar 31 11:52:15 alarmpi nginx[338]: 2020/03/31 11:52:15 [crit] 338#338: *43 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while keepalive, client:  server: 0.0.0    .0:443
 19 Mar 31 11:52:15 alarmpi nginx[338]: 2020/03/31 11:52:15 [crit] 338#338: *55 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while keepalive, client:  server: 0.0.0    .0:443
 20 Mar 31 11:52:15 alarmpi nginx[338]: 2020/03/31 11:52:15 [crit] 338#338: *47 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while keepalive, client:  server: 0.0.0    .0:443
 21 Mar 31 11:52:15 alarmpi nginx[338]: 2020/03/31 11:52:15 [crit] 338#338: *46 SSL_read() failed (SSL: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading) while keepalive, client:  server: 0.0.0    .0:443

I changed the upload limit in the /etc/php/php.ini

upload_max_filesize = 16G
max_execution_time = 86400
max_input_time = 86400
post_max_size = 16G

There is no code block in the nginx config with location ~ /\.(?!file).* {

In the Admin overview i have the following issues

  • It was not possible to execute the cron job via CLI. The following technical errors have appeared:

    • Your data directory is invalid Ensure there is a file called “.ocdata” in the root of the data directory.
  • The “X-Frame-Options” HTTP header is not set to “SAMEORIGIN”. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.

  • The “Strict-Transport-Security” HTTP header is not set to at least “15552000” seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips :arrow_upper_right:.

  • The “Referrer-Policy” HTTP header is not set to “no-referrer”, “no-referrer-when-downgrade”, “strict-origin”, “strict-origin-when-cross-origin” or “same-origin”. This can leak referer information. See the W3C Recommendation :arrow_upper_right:.

for the first error this is weird since

 $ ls -al /media/hdd1 | grep -i .ocdata                                                                                                                                     /usr/share/webapps/nextcloud
-rw-r--r--  1 http http      0 Mar 25 15:24 .ocdata

Hello, look in your parameters (admin) of NextCloud, in overview, you have a scan of security with errors of your configuration and hyperlink to resolve that.

Look also the app “Flow Upload”:

https://apps.nextcloud.com/apps/flowupload

I’ve heard of this problem before and if I recall it was among nginx users. I use Apache and Firefox and can drag and drop files 1-2 GB right into the web interface. This is on the official Docker version. Unfortunately I don’t know the fix.

what about client_max_body_size in the nginx.conf bzw. nextcloud.conf ?

or [URL REMOVED - Spam-protection [JK]]

or Uploading big files > 512MB — Nextcloud latest Administration Manual latest documentation

I checked and i have client_max_body_size 10G; in my nextcloud.conf

and I also applied the notes from the documentation. Still no luck

I remember that I modified somes configurations files to solve the problem.
In my case, I modified the following line :
"memory_limit = 1024M "
in all php.ini in /etc/php/7.3
For exemple:
/etc/php/7.3/fpm/php.ini
/etc/php/7.3/cli/php.ini

Maybe you have version 7.2 or 7.1

I also extented the memory limit

$ cat /etc/php/php.ini | grep -i memory_limit                                                                                                                                                           
memory_limit = 512M

dis you restart your php service after ?

what is the result of the followings lines :
cd /etc
find -name php.ini

here is the output

$ cd /etc
$ find -name php.ini 
./php/php.ini

Someone suggest

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

in my case it would be

sudo -u http php occ config:app:set files max_chunk_size --value 0

put i have no occ command where do I set the max_chunk_size

But dis you restart your php service ?
sudo systemctl restart php*

You dont have any php.ini elsewhere ?

Yes I restarted the service and rebooted the device.

There are no other php.ini files

I want to be sure :
php -r ‘phpinfo();’ | grep php.ini

I get no output

Sorry, its strange I cant help you more. You should have output (configuration file loaded).

Try to read the output of this :
php -r ‘phpinfo();’

(usually, configuration files loaded is int the first lines )

There are a few of php.ini files: cgi/php.ini, cli/php.ini, and you probably should edit fpm/php.ini only, because Nextcloud and WebDAV are webapplications.