I’m running a Nginx powered server I have configured a while ago. One problem I have on my wordprees sites hosted on that environment is that I couldn’t upload a files larger than 2MB. I got Nginx: 413 Request Entity Too Large error. After investigating I found the client_max_body_size directive determines the maximum accepted body size of client request. If size is greater than the given one, that’s when we get the error “Request Entity Too Large” (413).
If you’re getting 413 Request Entity Too Large errors trying to upload files to your webserver, you need to increase the client body size limit in your nginx.conf configuration file.
Fix Nginx 413 Request Entity Too Large
Step 1. First edit nginx.conf.
Add client_max_body_size in http section:
# set client body size to 2M #
Step 2. Restart Nginx web server to apply the changes.
service nginx restart
Step 3. Edit PHP configuration (optional).
Your php installation also put limits on upload file size. Edit php.ini and set the following directives:
;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 32M
;The maximum size of an uploaded file.
upload_max_filesize = 2M
;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 3M