I recently encountered a strange issue within the combination of Nginx and WordPress. I worte an article, and uploaded a bunch of images for this purpose. Most images uploaded fine, but a few threw http-errors. My php.ini had a lot higher limit and on the filesystem there was space. The only thing the images which did not upload had in common were, that they are rotated by 90 degrees. I have taken the images with my cellphone, and i knew that some phones put EXIF-tags that say „rotated by 90 degrees clockwise“ instead of actually transforming it.
But this was not the issue. As i took a closer look, I saw that the rotated images had a different filesize. Even though they all had the same resolution (~8mp) the landscape images were about half in size the portrait ones were. Very strange…
1 2 3 4 5 6 7 8 9 |
ls -alh drwx------ 2 zeus zeus 4,0K Jan 27 03:05 . drwxr-xr-x 9 zeus zeus 4,0K Jan 27 03:05 .. -rw-r--r-- 1 zeus zeus 643K Jan 27 00:08 IMG_20150711_195019.jpg -rw-r--r-- 1 zeus zeus 1,2M Jan 27 00:08 IMG_20150711_201512.jpg -rw-r--r-- 1 zeus zeus 1,2M Jan 27 00:08 IMG_20150712_123920.jpg -rw-r--r-- 1 zeus zeus 679K Jan 27 00:08 IMG_20150712_190652.jpg -rw-r--r-- 1 zeus zeus 707K Jan 27 00:08 IMG_20150712_190700.jpg -rw-r--r-- 1 zeus zeus 1,4M Jan 27 00:08 IMG_20150712_190723.jpg |
And this is exactly where a Limit is beeing hit. But at first i grepped some logs, which had shown a more detailed view on this:
1 2 |
root@server:~# grep error /var/log/nginx/error.log | tail -n 1 [error]: *92 client intended to send too large body: 1255733 bytes, server: blog.tastatursport.de, request: "POST ... |
A search for this offered, that there is a limit of 1MB default active in Nginx for files uploaded via POST-request. You might miss that, because (at least on debian & ubuntu so far i have seen) this is by default not in the nginx-config somewhere, so the default of 1MB is active.
Luckily you can just add this to your Nginx conf; either to /etc/nginx/nginx.conf or to a site-conf if not needed globally, but the following statement has to be somewhere inside the http{ } block:
1 |
client_max_body_size 30M; |
after restarting nginx everything worked like a charm. It took me some time to figure out where the actual problem was, I hope you will save some time then.
-zeus