5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

413 Request Entity Too Large 解決方法

Posted at

エラーの原因

このエラーは、アップロードしようとしたデータのサイズが大きすぎることが原因で発生していて、Nginxの設定を修正することで解決できます!

Nginx修正

nginx.confclient_max_body_sizeの設定を追加してあげます。
・下記のパスにnginx.confが配置されてるかと思います。

[root@ip-???-??-??-??? ~]# cd /etc/nginx
[root@ip-???-??-??-??? nginx]# vi nginx.conf

1.nginx.confに追加

server {
    client_max_body_size 20M; # 追加
    listen       80;
    listen       [::]:80;
    server_name  _;
    root         /var/www/current/backend/public;

2.nginxをリロード

[root@ip-???-??-??-??? nginx]# service nginx reload

3.nginxの起動確認
緑文字でactive (running)が表示されれば正常にnginxが動作しています。

[root@ip-???-??-??-??? nginx]# sudo systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           └─php-fpm.conf
   Active: active (running) since Thu 2022-03-24 12:43:45 UTC; 10min ago
  Process: 17808 ExecReload=/usr/sbin/nginx -s reload (code=exited, status=0/SUCCESS)
  Process: 17701 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 17697 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 17696 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 17703 (nginx)
   CGroup: /system.slice/nginx.service
           ├─17703 nginx: master process /usr/sbin/nginx
           └─17809 nginx: worker process

Mar 24 12:43:45 ip-???-??-??-???.ap-northeast-1.compute.internal systemd[1]: Starting The nginx...
Mar 24 12:43:45 ip-???-??-??-???.ap-northeast-1.compute.internal nginx[17697]: nginx: the confi...
Mar 24 12:43:45 ip-???-??-??-???.ap-northeast-1.compute.internal nginx[17697]: nginx: configura...
Mar 24 12:43:45 ip-???-??-??-???.ap-northeast-1.compute.internal systemd[1]: Started The nginx ...
Mar 24 12:54:35 ip-???-??-??-???.ap-northeast-1.compute.internal systemd[1]: Reloading The ngin...
Mar 24 12:54:35 ip-???-??-??-???.ap-northeast-1.compute.internal systemd[1]: Reloaded The nginx...
Hint: Some lines were ellipsized, use -l to show in full.

4.ファイルのアップロード確認
再度ファイルをアップロードしてエラーが出なければ成功です!

参考記事

5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?