You may receive the error 403 “Request Entity Too Large Error” when trying to upload a large file in Nginx. By default, nginx only allows files less than 1 MB. To increase that limit, you will have to add the following to your nginx.conf file:
client_max_body_size 4M;
The number 4 should be changed to however megabytes you want the limit to be. Do note it’s 4M for 4 megabytes, rather than 4MB. After having added that to your configuration file, you should restart nginx for this change to take effect. Do note the command may differ, but should be the following if you installed from a RPM/DEB package or setup the startup script from our Nginx Startup Script post.
/etc/init.d/nginx restart
Even after increasing nginx’s upload limit, the PHP limit may also be limiting how large of a file you can upload. You will want to change the post_max_size and upload_max_filesize values in your php.ini file as well. Note that if you make a change here, most likely you will have to restart the spawn-fcgi process to make the change live.