Monday, March 4, 2013

Nginx client intended to send too large body

If you see the message "client intended to send too large body" in the nginx log file (/var/log/nginx/error.log), you need to set the size of client_max_body_size.

You can set client_max_body_size in the context of http, server, location.

For example, in your .conf file:


server {
        listen 80;
        server_name domain.com;
        access_log /vol/logs/nginx/web_portal.access.log;

        location / {

                if ($http_x_forwarded_proto != 'https') {
                        rewrite ^ https://$host$request_uri? permanent;
                }

                proxy_pass      http://domain.com
                proxy_next_upstream error timeout invalid_header http_500;
                proxy_connect_timeout 1;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;

                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_intercept_errors on;
                error_page 502 503 504 =200 http://domain.com;
                client_max_body_size 650M;
        }
}


1 comment:

  1. very interesting post.this is my first time visit here.i found so many interesting stuff in your blog especially its discussion..thanks for the post!
    Minecraft Server List

    ReplyDelete