docker icon indicating copy to clipboard operation
docker copied to clipboard

Nextcloud 18 update: upload_max_filesize 2 MB

Open paderick opened this issue 6 years ago • 27 comments

Since the update to nc 18 the upload and post max size is decreased to 2MB.

I can't find a way to set a larger filesize. Please help.

paderick avatar Feb 26 '20 21:02 paderick

I am running nextcloud 18 from the official docker images.

In the admin settings -> system -> PHP, Upload max size is showing 2MB. However, I am still able to upload large files (tested a 700MB file) via a browser. I am using nginx as a proxy which is setup with client_max_body_size 10G.

According to the documentation, these settings can be changed with nextcloud/.htaccess and nextcloud/.user.ini. In .htaccess and .user.ini, upload_max_filesize and post_max_size is both 511M, and memory_limit is 512M (auto-generated default values). Changing the values there doesn't change anything in the nextcloud settings UI (even after a container restart).

I found that changing settings in /usr/local/etc/php/conf.d/memory_limit.php has an effect. Changes in this file are actually reflected in the admin settings interface.

This is odd, as changing values there is not persistent - /usr/local/etc/php/conf.d/ is not a volume. Moreover this is not documented, and the official documentation seems wrong. Moreover, what's the recommended value for nextcloud? From the browser, I see that big files are uploaded in 10MB chunks (which works even if nextcloud shows 2MB max upload size).

choffm avatar Mar 05 '20 13:03 choffm

The changes in memory-limits.php take effect, after restarting the container.

@pierreozoux: But why isn't there a way to change the values permanently?

paderick avatar Mar 06 '20 15:03 paderick

You can add own file by volume all files from conf.d folders are loaded: in docker-compose.yml

- ./php.ini:/usr/local/etc/php/conf.d/zzz-custom.ini

or by the docker command

-v /path/to/your/php.ini:/usr/local/etc/php/conf.d/zzz-custom.ini

And the file can look like:

upload_max_filesize=512M
post_max_size=550M
memory_limit=1G

then restart the container and this should work

gbalcewicz avatar Mar 06 '20 17:03 gbalcewicz

I am wondering why per default, upload_max_filesize and post_max_size are both 2 MB, but uploading large files is still possible. Is nextcloud served via apache using the values from .htaccess or .user.ini, but occ uses the globally defined ones (/usr/local/etc/php/conf.d/)? So in the end, this modificationi isn't even required?

choffm avatar Mar 06 '20 20:03 choffm

or by the docker command

-v /path/to/your/php.ini:/usr/local/etc/php/conf.d/zzz-custom.ini

@gbalcewicz, can you add to an existing container with this command? Also, I guess that you need to have more perameters in that command? Maybe understood by most, but I am still very much learning how to manage Docker containers. Big thanks in advance!

b3nis avatar Mar 07 '20 12:03 b3nis

For example in this command.

docker run -d \
-v nextcloud:/var/www/html \
-v apps:/var/www/html/custom_apps \
-v config:/var/www/html/config \
-v data:/var/www/html/data \
-v theme:/var/www/html/themes/<YOUR_CUSTOM_THEME> \
-v /path/to/your/php.ini:/usr/local/etc/php/conf.d/zzz-custom.ini
nextcloud

In the README there are different scenarios and it's just another command parameter to fit your needs. The -v parameter tells docker to mount file as the zzz-custom.ini (volumes don't have to be directories, they can be single files also). The zzz is to ensure that this config will load last and override other ini files in that directory.

gbalcewicz avatar Mar 07 '20 12:03 gbalcewicz

Thanks a lot @gbalcewicz! It works! Nextcloud now reports 2GB for PHP. You are amazing.

b3nis avatar Mar 07 '20 14:03 b3nis

And the file can look like:

upload_max_filesize=512M
post_max_size=550M
memory_limit=1G

I'm still having issues with this. Even setting 512 to .ini file I still can upload files larger than 512MB. I'm using Docker Apache Imagem from Nextcloud 20.

Any tips?

wiltonsr avatar Nov 04 '20 00:11 wiltonsr

Hi @wiltonsr, did you tried out @gbalcewicz's answer? In the worst case try the following:

docker exec -it nextcloud /bin/bash
vi /usr/local/etc/php/conf.d/memory-limit.ini

add there your three lines, save and exit the file, exit the container and restart it.

paderick avatar Nov 10 '20 20:11 paderick

Hi @paderick, thanks for answering.

I tried exactly this solution and the NC simply ignores the parameter and I can upload any size file. I ran the test with a 2GB file and the upload worked.

wiltonsr avatar Nov 10 '20 21:11 wiltonsr

@wiltonsr sorry - I've no idea.
Is the file stored correctly after your test-upload?

paderick avatar Nov 10 '20 21:11 paderick

I believe so Confirmed. The file is uploaded correctly.

image

Even if I execute php -i | grep upload_max_filesize inside container I have the following return upload_max_filesize => 512M => 512M that is expected by the configuration file. However, I can still upload larger files.

wiltonsr avatar Nov 10 '20 21:11 wiltonsr

@wiltonsr It's not a bug, it's a feature!

paderick avatar Nov 10 '20 21:11 paderick

Can you paste command you are using to run the container?

gbalcewicz avatar Nov 10 '20 21:11 gbalcewicz

Dockerfile:

FROM nextcloud:20

COPY ./custom.ini "$PHP_INI_DIR/conf.d"

custom.ini

upload_max_filesize=512M
post_max_size=550M
memory_limit=1G

Build commando: docker build -t my-next .

Run command: docker run -p 8080:80 --rm --name next my-next

wiltonsr avatar Nov 10 '20 21:11 wiltonsr

It could be the order of the configs are loaded, did you try to rename the custom.ini to zzz-custom.ini?

gbalcewicz avatar Nov 10 '20 21:11 gbalcewicz

Even when I execute with docker run -p 8080:80 --rm --name next nextcloud:20 using a non-builded image and dont changing any config, which that returns the default value upload_max_filesize => 2M => 2M I can still upload larger files.

It is as if the NC just ignores the PHP values.

wiltonsr avatar Nov 10 '20 21:11 wiltonsr

Are you uploding with sync client? If yes in the docs https://docs.nextcloud.com/server/15/admin_manual/configuration_files/big_file_upload_configuration.html there is a note that says the limit won't work as the files are sent in small chunks

gbalcewicz avatar Nov 10 '20 22:11 gbalcewicz

How can I check if sync client is enabled? Enabled is the default value, because in the last test there is no change in containers.

From logs, I saw many lines scrolling when upload ocurrs.

wiltonsr avatar Nov 10 '20 22:11 wiltonsr

The documentation refers to the desktop and mobile clients, when mentioning sync clients. Even he browser UI uploads large files in 10M chunks.

choffm avatar Nov 11 '20 22:11 choffm