nginx 出现413 Request Entity Too Large问题的解决方法

7 min read
<html>
 <head><title>413 Request Entity Too Large</title></head>
 <body bgcolor="white">
 <center><h1>413 Request Entity Too Large</h1></center>
 <hr><center>nginx/1.10.3</center>
 </body>
 </html>
 <!-- a padding to disable MSIE and Chrome friendly error page -->
 <!-- a padding to disable MSIE and Chrome friendly error page -->
 <!-- a padding to disable MSIE and Chrome friendly error page -->
 <!-- a padding to disable MSIE and Chrome friendly error page -->
 <!-- a padding to disable MSIE and Chrome friendly error page -->
 <!-- a padding to disable MSIE and Chrome friendly error page -->

解决方法如下:

1.打开nginx配置文件 nginx.conf, 路径一般是:/etc/nginx/nginx.conf。

2.在http{}段中加入 client_max_body_size *20m*; 20m为允许最大上传的大小。

3.保存后重启nginx,问题解决。

server {
    listen 80;
    server_name git.xxxx.de;
    client_max_body_size 100M; # Push large objects to gitea

    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}