fatal: the remote end hung up unexpectedly / 413 Request Entity Too Large
Nginx Upload Module – Nginx Guts
Module ngx_http_core_module/client_body_temp_path
Nginx failed space when upload – Server Fault
问题描述
# git push -u origin master Enumerating objects: 15899, done. Counting objects: 100% (15899/15899), done. Delta compression using up to 4 threads Compressing objects: 100% (8080/8080), done. error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large fatal: the remote end hung up unexpectedly Writing objects: 100% (15899/15899), 75.80 MiB | 102.40 MiB/s, done. Total 15899 (delta 8964), reused 13944 (delta 7312) fatal: the remote end hung up unexpectedly Everything up-to-date
问题原因
看到错误日志中的 413 Request Entity Too Large 提示,我们就立刻想到是 Nginx 配置原因。通常较大的仓库会遇到该问题。
解决办法
在 Nginx 中,添加 client_max_body_size 配置:
server { listen 80; server_name gogs.example.com; client_max_body_size 200m; location / { proxy_pass http://127.0.0.1:6000; } }
fatal: the remote end hung up unexpectedly
问题描述
在 git push 时,产生如下错误:
... fatal: the remote end hung up unexpectedly ...
原因分析
根据 Nginx 日志:
... pwrite() "/var/lib/nginx/tmp/client_body/0000000002" failed (28: No space left on device), ...
我们提交的文件比较大,导致磁盘没有足够空间来缓存提交数据。
解决方案
增加磁盘空间,保证有足够的磁盘空间来缓存临时上传文件。
或者,修改临时上传目录的路径(client_body_temp_path):
# mkdir -pv /srv/tmp/nginx # chown nginx: /srv/tmp/nginx/ # chmod -v o+x /srv /srv/tmp # vim /etc/nginx/conf.d/gogs.conf server { ... client_body_temp_path /srv/tmp/nginx; ... }