LoginSignup
94
82

More than 5 years have passed since last update.

nginxで"client intended to send too large body"が発生した時の対策方法

Last updated at Posted at 2013-11-15

nginx が稼働しているWebページで、フォームからファイルをアップロードしようとしたら、
"1 client intended to send too large body: 1367171 bytes" というエラーが発生しました。

これは、nginx が POST の最大サイズを超えるデータが送られてきた場合に発生するエラーのようです。

http://wiki.nginx.org/HttpCoreModule#client_max_body_size
によると、nginx ではデフォルトで1MBまでのデータしか受け付けないようです。

nginx が1MBより大きなデータを受け取れるようにするには、nginx.conf で client_max_body_size ディレクティブを設定します。

client_max_body_sizehttp, server, locationコンテキスト内で使用できます。

nginx.conf
http {
    client_max_body_size 1048576; # default 1m

    server {
        client_max_body_size 100m;

        location ~ ^/upload/ {
            client_max_body_size 2g;
        }
    }
}
94
82
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
94
82