Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

Lychee ignoring max_upload_size

Open ssttkk opened this issue 5 years ago • 4 comments

Detailed description of the problem [REQUIRED]

Just after my fresh install of Lychee, I'mp trying to upload some quite big pictures of mine, around 18Mb each. Everytime I try, I get rejected with a "The PHP_post_max_size is too small"

image

(Note : ulpoading a small picture works just fine)

even after updated everything I can to increase that size :

  • modified the values in cli/php.ini and fpm/php.ini
  • modified the values in Lychee/public/.user.ini
  • modified the value in my nginx configuration file for Lychee

After experimenting and putting up different values in those places, I found out that the file being used is the one in Lychee/public/.user.ini . The sizes in this one correspond to the one in the Diagnostics tab.

the error related to the upload in the logs is : 2021/07/11 17:35:42 [error] 31841#31841: *80 client intended to send too large body: 17324313 bytes, client: redacted, server: redacted, request: "POST /api/Photo::add HTTP/1.1", host: "redacted", referrer: "http://redacted/gallery"

In the diagnostic, the values seem fine, but apparently it is not enough :

Output of the diagnostics [REQUIRED]

System Information
--------------
Lychee Version (git):            master (8d41c0f) - Data not in Cache
DB Version:                      4.3.4

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

System:                          Linux
PHP Version:                     7.4
Max uploaded file size:          100M
Max post size:                   200M
MySQL Version:                   10.3.29-MariaDB-0+deb10u1

Imagick:                         -
Imagick Active:                  1
Imagick Version:                 -
GD Version:                      2.2.5




Config Information
--------------
version:                         040304
check_for_updates:               0
sorting_Photos_col:              taken_at
sorting_Photos_order:            ASC
sorting_Albums_col:              max_taken_at
sorting_Albums_order:            ASC
imagick:                         1
skip_duplicates:                 0
small_max_width:                 0
small_max_height:                360
medium_max_width:                1920
medium_max_height:               1080
lang:                            fr
layout:                          1
image_overlay_type:              desc
default_license:                 none
compression_quality:             90
full_photo:                      1
delete_imported:                 0
Mod_Frame:                       1
Mod_Frame_refresh:               30
thumb_2x:                        1
small_2x:                        1
medium_2x:                       1
landing_page_enable:             1
landing_owner:                   x
landing_title:                   x
landing_subtitle:                Misc
landing_facebook:                
landing_flickr:                  
landing_twitter:                 
landing_instagram:               x
landing_youtube:                 
landing_background:              
site_title:                      x
site_copyright_enable:           1
site_copyright_begin:            2019
site_copyright_end:              2025
additional_footer_text:          
display_social_in_gallery:       0
public_search:                   0
SL_enable:                       0
SL_for_admin:                    0
public_recent:                   0
recent_age:                      1
public_starred:                  0
downloadable:                    0
photos_wraparound:               1
map_display:                     0
zip64:                           1
map_display_public:              0
map_provider:                    Wikimedia
force_32bit_ids:                 0
map_include_subalbums:           0
update_check_every_days:         3
has_exiftool:                    0
share_button_visible:            0
import_via_symlink:              0
has_ffmpeg:                      0
location_decoding:               0
location_decoding_timeout:       30
location_show:                   1
location_show_public:            0
rss_enable:                      0
rss_recent_days:                 7
rss_max_items:                   100
prefer_available_xmp_metadata:   0
editor_enabled:                  1
lossless_optimization:           0
swipe_tolerance_x:               150
swipe_tolerance_y:               250
local_takestamp_video_formats:   .avi|.mov
log_max_num_line:                1000
unlock_password_photos_with_url_param: 0
nsfw_visible:                    1
nsfw_blur:                       0
nsfw_warning:                    0
nsfw_warning_admin:              0
map_display_direction:           1
album_subtitle_type:             oldstyle
upload_processing_limit:         4
public_photos_hidden:            1

Browser and system

System is Debian 10 (4.19.0-8-amd64 #1 SMP Debian 4.19.98-1+deb10u1 (2020-04-27) x86_64 GNU/Linux) Browser is Firefox 89.0.2 (64 bits)

ssttkk avatar Jul 11 '21 15:07 ssttkk

Is there anything upstream of the Lychee nginx? e.g. another nginx? Also, just to check, those diagnostics were from the webpage not the CLI?

d7415 avatar Jul 11 '21 16:07 d7415

There's no other nginx in front of the one for Lychee. The only place where I move a bit from the official installation is that my Lychee is not in the root of my nginx, but in a subfolder : /var/www/sites/site-name/Lychee

Also, just to check, those diagnostics were from the webpage not the CLI?

My diagnostics were from the webpage indeed, but when I run it in CLI, I get values from my php7.4/cli/php.ini (which makes sense to me)

My nginx conf :

server {
    listen 80;
    server_name site-name;

    root /var/www/sites/site-name/Lychee/public/;

    location / {
        try_files $uri /index.php;
    }

    # If the request is not for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # Serve /index.php through PHP
    location = /index.php {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;

        fastcgi_param HTTP_PROXY "";

        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PHP_VALUE "post_max_size=200M \n max_execution_time=200 \n upload_max_filesize=200M \n memory_limit=512M";
        fastcgi_param PATH /usr/local/bin:/usr/bin:/bin;
        include fastcgi_params;
    }
    location ~ [^/]\.php(/|$) {
        return 403;
    }

    error_log  /var/log/nginx/lychee.error.log;
    access_log /var/log/nginx/lychee.access.log;

    rewrite ^/(.+)/$ /$1 permanent;
}

ssttkk avatar Jul 11 '21 16:07 ssttkk

Replying to myself to close this issue. The problem was not within Lychee itself, the upload problem was fixed by adding a client_max_body_size to my nginx.conf file. I thought it was a php / Lychee problem at first beacause of the error message displaying "The PHP_post_max_size is too small".

ssttkk avatar Jul 12 '21 16:07 ssttkk

Ah, I should have checked for that in the config you provided - sorry. And yes, we should definitely reword that error message.

Thanks for getting back to us!

d7415 avatar Jul 12 '21 17:07 d7415