Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx client_max_body_size not working

Tags:

nginx

This should be a quick fix. So for some reason I still can't get a request that is greater than 1MB to succeed without returning 413 Request Entity Too Large.

For example with the following configuration file and a request of size ~2MB, I get the following error message in my nginx error.log:

*1 client intended to send too large body: 2666685 bytes,

I have tried setting the configuration that is set below and then restarting my nginx server but I still get the 413 error. Is there anything I am doing wrong?

server {
    listen      8080;
    server_name *****/api; (*omitted*)

    client_body_in_file_only clean;
    client_body_buffer_size 32K;
    charset     utf-8;
    client_max_body_size 500M;
    sendfile on;
    send_timeout 300s;
    listen 443 ssl;
    location / {
        try_files $uri @(*omitted*);
    }
    location @parachute_server {
        include uwsgi_params;
        uwsgi_pass    unix:/var/www/(*omitted*)/(*omitted*).sock;
    }
  }

Thank you in advance for the help!

like image 967
Daniel Gaeta Avatar asked Aug 26 '16 04:08

Daniel Gaeta


People also ask

What is client_max_body_size in nginx?

Context: http , server , and location. This is the maximum size of a client request body. If this size is exceeded, Nginx returns a 413 Request entity too large HTTP error. This setting is particularly important if you are going to allow users to upload files to your server over HTTP.

How do I fix Nginx 413 Request Entity Too Large?

The solution is to increase the client request size body by the client_max_body_size parameter in nginx. conf file. Following is the description of the client_max_body_size parameter. The default value is 1MB and you can set this to an HTTP, server or location contexts.

Where is client_max_body_size?

In the opened “/etc/nginx/nginx. conf” file, look for the line assigning the value to the “client_max_body_size” variable in the “http {}” section. You can add the “client_max_body_size” value manually if you cannot find it in the configuration file.


1 Answers

I'm surprised you haven't received a response but my hunch is you already have it set somewhere else in another config file.

Take a look at nginx - client_max_body_size has no effect

like image 163
CYMA Avatar answered Nov 02 '22 05:11

CYMA