Nginx Error - 413 Request Entity Too Large

nginx version: nginx/1.1.19, OS: Ubuntu12.04
Default nginx accepted body size limitation is 1MB.
You can add client_max_body_size in nginx.conf.
This parameter can put in http, server and location sections of configutation file.
Enlarge body size to 10MB

client_max_body_size 10M  

Or just disable it

client_max_body_size 0  

For example enlarge body size to 10MB
Add to http section:

$ sudo vi /etc/nginx/nginx.conf  

http {

        # Basic Settings

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        client_max_body_size 10M;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

Or modify server and location section

$ sudo vi /etc/nginx/sites-available/default  

server {
        #listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6
        client_max_body_size 10M;
        root /usr/share/nginx/www;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
                client_max_body_size 0;

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                deny all;

Reload configuration:

$ sudo service nginx reload  


Leave a Comment