2012年10月17日水曜日

Request Entity Too Largeエラーが出る。原因はLimitRequestBodyだった

ウェブアプリで2MBのファイルをPOSTでアップロードする処理をしたら、

HTTP 413
Request Entity Too Large

The requested resource
/test.php
does not allow request data with POST requests, or the amount of data
provided in the request exceeds the capacity limit.


というエラーが。
「Request Entity Too Large」でググるとnginx関係のエラーが出てきますが、ウチのサーバーはnginxなんて入れてないので、おかしいな~と思ってました。

で、httpdのエラーログを確認すると、

Requested content-length of 2073274 is larger than the configured limit of 1024000


と出てました。
なんか制限かけてるようです。

とりあえずhttpd.confで「1024000」を検索かけてみたところ、

LimitRequestBody 1024000


という記述が。明らかにこれが怪しいです。

ゼロをひとつ増やしてhttpdを再起動したら、エラーが出なくなりました。

なんの目的でLimitRequestBodyを設定したのか記憶にないのですが、テスト環境なんで消し忘れとかだと思います。