LycheeOrg / Lychee-Docker

Docker image for Lychee
https://lycheeorg.github.io/
167 stars 55 forks source link

"Upload failed. PHP post_max_size is to small" even after changing nginx.conf #144

Closed lilian-pouliquen closed 1 year ago

lilian-pouliquen commented 1 year ago

Hello, I was trying to upload a video that exceed the default 100 MB allowed by Lychee and got the following error:

Upload failed. PHP post_max_size is to small

I tried to change the defaults by setting the following in the nginx.conf:

client_max_body_size 500M;
fastcgi_param PHP_VALUE "max_execution_time=3600
    memory_limit=512M
    post_max_size=500M
    upload_max_filesize=500M";

I recreated the container with the modified nginx.conf mounted but I get the same error. I searched if there was already an issue that help solving this but nothing more than follow the documentation as I did.

If you need any piece of information, please tell me. Here is the diagnostics of Lychee:

System Information
--------------
Lychee Version (git):                    ?? (60c6f34) -- Could not compare.
DB Version:                              4.7.0

composer install:                        --no-dev
APP_ENV:                                 production
APP_DEBUG:                               true

System:                                  Linux
PHP Version:                             8.1.12
PHP User agent:                          Lychee/4 (https://lycheeorg.github.io/)
Timezone:                                Europe/Paris
Max uploaded file size:                  500M
Max post size:                           500M
Max execution time:                      3600
PostgreSQL Version:                      PostgreSQL 15.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit

exec() Available:                        yes
Imagick Available:                       1
Imagick Enabled:                         1
Imagick Version:                         1691
GD Version:                              2.3.3
Number of foreign key:                   11 found.

Thank you for your help.

d7415 commented 1 year ago

Hi. Did you also update the line client_max_body_size 100M; in the nginx config? It may also be worth checking any upstream reverse proxies/etc.

I remember thinking in the past that that error needs changing, but I haven't done it yet. The actual error is

Upload failed. The PHP post_max_size may be too small! Otherwise check the FAQ.

so is correct.

lilian-pouliquen commented 1 year ago

Hi, thanks for your answer. I already changed the client_max_body_size to match the wanted post size (500 MB). However, I did not check the upstream reverse-proxies.

My server is behind Cloudflare and I use HAProxy for my reverse-proxies. I found that HAProxy has no limit in upload. I searched a bit more and found that Cloudflare is limiting uploads to 100 MB for free and pro plans.

Thanks for your help again, I would not have thought of the reverse-proxies.

d7415 commented 1 year ago

Ah, good to know. Glad to help!

mck182 commented 1 year ago

I had the exact same issue - running the latest docker image and also have adjusted the nginx.conf file as per the documentation but I was still getting

Upload failed. The PHP post_max_size may be too small! Otherwise check the FAQ.

I just wanted to confirm the culprit was indeed a reverse proxy, in this case it was nginx running in another docker container, since it has the default upload limit set to 1M.

Setting

http {
  ...
  client_max_body_size 100M;
  ...
}

in the reverse-proxy config fixed the issue (could also be set in the server { .. } section for single app).

Just wanted to mention that, hoping it helps someone else too!