WordPress HTTP Error on Nginx
It happened to me few days back when i try to upload an image via WordPress media library over 1MB of size. WordPress would throw an error
Well the error is not that descriptive and one would think what could be the problem, is it a permission issue. Most probably not because you may upload images less 1MB and that got uploaded. So its not permission issue. Then what could be the issue?, the answer is simple.
If you have your own VPS lets say with DigitalOcean OR Linode etc running Nginx and WordPress. Chances are that you may have missed one line to add to your server block in nginx.conf OR any conf file inside conf.d dir which your server is listening to. So lets fix this, login to your server via terminal and type if your are root already.
vim or vi or nano choice is yours, i prefer vim. Now default.conf may be different for you, so change it to the file you want to edit. If your server is listening to nginx.conf then run the 2nd command.
Inside that file look for server block and add the following line to it:
4m means upload file limit would be 4MB, change it your desired number. Check if there is no error in the conf file:
If no errors, restart the web server. If got errors, check the error and fix that.
systemctl restart nginx
Thats pretty much it.
NOTE: If you get max upload file size 2MB, that means your php.ini only allow 2MB. For this to make it work open /etc/php.ini and change these:
upload_max_filesize = 8M post_max_size = 10M
And now restart php-fpm:
systemctl restart php-fpm systemctl restart nginx