2

i have nginx on centOS distro. Everything is configured to upload files fine for me..

  • in etc/php.ini (dont know why on centos this file is in root of etc but its working) i have upload_max_filesize 60M, client_max_body_size 80M and post_max_size 80M.

Other files like nginx server configuration have these upload directives too.

But when I'm uploading a 1mb file nginx is erroring 413 Request Entity Too Large. My web app is showing that server have 60mb file limit like info.php file. I did a reboot, nginx reload, restart, php reload.

I have checked everything on stackoverflow and net to fix this but nothing helped.

Nginx logs: Nginx is showing that user is trying to upload bigger file than limit.

There is a pdf of my info.php file: http://docdro.id/YAylJcO

2 Answers 2

2

Have you edited your nginx.conf. Add client_max_body_size xxM inside the server section, where xx is the size (in megabytes) that you want to allow.

Sign up to request clarification or add additional context in comments.

1 Comment

This helped, thank you!! i filled there only upload max and post max. Wow.
0

By default, nginx is configured to allow a client maximum body size of 1MB. The files you are uploading (~8MB) are larger than 1MB, which is why the 413 (Request Entity Too Large) error is being returned.

To fix this issue, simply edit nginx.conf and add a client_max_body_size configuration like so:

    ######################
    # HTTP server
    ######################
    server {
        ...
        listen       80;
        server_name  xxxx.com;
        client_max_body_size 20M;
        ...
    }

If you have HTTPS configured as well, be sure to add client_max_body_size there as well:

    ######################
    # HTTPS server
    ######################
    server {
        ...
        listen       443 default_server ssl;
        server_name  xxxx.com;
        client_max_body_size 20M;
        ...
    }

reload your server and you should be good!

[server]$ sudo service nginx reload


More info on client_max_body_size here: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

Syntax: client_max_body_size size;

Default: client_max_body_size 1m;

Context: http, server, location

Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables checking of client request body size.

1 Comment

Isn't there something like multi part file upload where file is splited and then you don't need to increase client_max_body_size?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.