Parse server not uploading file > 1mb, logs in server: “client intended to send too large body”

I recently encountered this error on Parse to upload a PFFile whose size is around 2Mb but got a  “HTTP error” in red. And I saw nginx’s error log which contained this error:
The nginx error log located at /var/log/nginx/error.log contained the following line
[error] 31354#0: *10899 client intended to send too large body: 1198151 bytes, client: <IP address>, server: example.com, request: “POST /wp-admin/async-upload.php HTTP/1.1”, host: “example.com”, referrer: “http://example.com/wp-admin/post.php?post=<post id>&action=edit”

From this error we can understand that an attempt to upload a file using POST method was made which ended up with the error “client intended to send too large body” to fix this a nginx directive named client_max_body_size has to be created/modified. Open the nginx configuration file

vi /etc/nginx/nginx.conf
add or modify the following line inside http {…}
client_max_body_size 20M;
then reload nginx
service nginx reload
This will allow file uploads with sizes upto 20MB, the default value of this directive is 1M which is the reason why this error occurs. Alternatively this directive can be used inside the server {…} or location{…} contexts if you want this setting to apply only to a particular vhost or location.

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注