GitLab 使用git push 出现RPC failed; HTTP 500 curl 22 The requested URL returned error: 500

提交流程图时,出现了如下奇怪错误:

$ git push origin
Counting objects: 4, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 5.59 MiB | 16.73 MiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
error: RPC failed; HTTP 500 curl 22 The requested URL returned error: 500 Internal Server Error
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

6MB不到的文件居然提交失败,之前20M的文件都提交过.

网上搜了下,大多是说使用git config --global http.postBuffer 524288000将本地http的缓存加大到500MB,但试了下,依旧是这样的错误.于是翻了下gitlab的官方Issue.找到两个:

第一个Issue是说Gitlab中的配置需要修改,我的gitlab是跑在容器中,因此修改gitlab与nginx限制:

  • gitlab/config/gitlab.rb,修改了gitlab_rails['git_max_size'] = '524288000',增加到500MB.

  • nginx['client_max_body_size'] ='0',关闭nginx对上传内容的长度限制.

遗憾的是依旧无效.

第二个Issue中大伙挨个分析了错误的响应,并给出了几个解决办法,仍然是依旧无效.

我对着日志挨个检查了一遍,发现错误在logs/nginx/gittlab_error.log中,错误内容为:

[crit] 468#0: *101 open() "/var/opt/gitlab/nginx/client_body_temp/0000000001" failed (13: Permission denied)  ...
...

看到这条便恍然,前两天将gitlab服务迁移到群晖下后,是文件夹权限变更导致的.因此git push文件时,size比较小的文件比如2K或者3K的代码提交很快,因为nginx根本不缓存.但是当文件只要稍大时,nginx必将缓存一下,这时权限问题便出现.

因此修改一下权限即可: nginx/client_body_temp/权限改为** 0700 **.

If you move gitlab’s data folder, please check logs/nginx/gittlab_error.log,and in most cases, /var/opt/gitlab/nginx/client_body_temp/ Permission denied . So,just change client_body_temp permission to 700 :

chmod 700 data/nginx/client_body_temp