By piwigo website was broken; when I uploaded new pictures, they would not appear on the page. At first I thought resizing with GD was the problem, but switching to Imagick didn’t help either.
The rewrite rules of nginx turned out to be the problem.
I had a location block in my virtual host that would serve static files directly. But this rewrite rule was hit while the uploading process was trying to use the i.php script for processing the upload.
The easiest way would be to just remove the static file serving part, but instead, I tried looking for a regex that would still serve static files directly, but just not the ones that needed processing. So, in fact, the ones starting with /i or /i.php.
So, eventually my virtual host looks something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# This can also go in the http { } level index index.html index.htm index.php; location / { # if you're just using wordpress and don't want extra rewrites # then replace the word @rewrites with /index.php try_files $uri $uri/ @rewrites; } location @rewrites { # Can put some of your own rewrite rules in here # for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last; # If nothing matches we'll just send it to /index.php # The following is needed for batch operations which use i.php rewrite ^/i((/|$).*)$ /i.php$1 last; rewrite ^/picture((/|$).*)$ /picture.php$1 last; rewrite ^/index((/|$).*)$ /index.php$1 last; } # LET OP!!!! PIWIGO gaat misschien wel stuk van onderstaand blokje!! # This block will catch static file requests, such as images, css, js # The ?: prefix is a 'non-capturing' mark, meaning we do not require # the pattern to be captured into $1 which should help improve performance location ~* ^/(?!(i/|i\.php/))(.*)\.(?:ico|css|js|gif|jpe?g|png)$ { # Some basic cache-control for static files to be sent to the browser expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } # remove the robots line if you want to use wordpress' virtual robots.txt location = /robots.txt { access_log off; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } # this prevents hidden files (beginning with a period) from being served location ~ /\. { access_log off; log_not_found off; deny all; } location ~ ^(?.+?\.php)(?/.*)?$ { try_files $script_name = 404; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |