Title: Git PUSH results in RPC failed, result=22, HTTP code = 413
date: 2016-05-17
comments: true
category: Git
tags: git,gitlab
git push 413 error
今天git push
具体的错误信息如下,查看发现里面有个第三方SDK大小为32M
git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/master:refs/heads/master
Pushing to http://xxx.xxx.xxx.xxx:xxx/IOS/ios.git
POST git-receive-pack (21702686 bytes)
error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
Completed with errors, see above
分析
本地搭建的gitlab是基于 sameersbn的docker-gitlab服务,是基于nginx服务访问的。
一般出现413是nginx的Request Entity Too Large错误,是说上传的请求体太大导致的。
解决的办法一般是在nginx配置文件中新增 client_max_body_size 参数。
解决
查看并进入gitlab container里面
root@pts/3 $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92ca050a601e sameersbn/gitlab:7.10.1 "/app/init app:start 8 months ago Up 13 days 443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp shell_gitlab_1
6fc427139751 sameersbn/redis:latest "/sbin/entrypoint.sh 8 months ago Up 13 days 6379/tcp shell_redis_1
60c123ed03d1 sameersbn/postgresql:9.4 "/start" 8 months ago Up 13 days 5432/tcp shell_postgresql_1
milian-backend [/tmp/liuchao] 2016-05-30 16:56:26
root@pts/3 $ docker exec -it 92ca050a601e /bin/bash
root@92ca050a601e:/home/git/gitlab#
检查nginx并修改配置
root@92ca050a601e:/home/git/gitlab# cat /etc/nginx/nginx.conf |egrep client_max_body_size
client_max_body_size 50M;
root@92ca050a601e:/home/git/gitlab# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@92ca050a601e:/home/git/gitlab# nginx -s reload
root@92ca050a601e:/home/git/gitlab#
再 git push
测试,发现还是有问题。继续查找...
找到根源并解决
## 发现有包含配置文件
root@92ca050a601e:/home/git/gitlab# cat /etc/nginx/nginx.conf |egrep include
include /etc/nginx/mime.types;
include /etc/nginx/sites-enabled/*;
root@92ca050a601e:/home/git/gitlab# ls -l /etc/nginx/sites-enabled/
total 8
-rw-r--r-- 1 root root 4569 May 30 11:13 gitlab
## 发现大小限制到了20m
root@92ca050a601e:/home/git/gitlab# cat /etc/nginx/sites-enabled/gitlab |egrep client_max_body_size
client_max_body_size 20m;
## 修改/etc/nginx/sites-enabled/gitlab中的client_max_body_size为50m
root@92ca050a601e:/home/git/gitlab# cat /etc/nginx/sites-enabled/gitlab |egrep client_max_body_size
client_max_body_size 50m;
## 使其生效
root@92ca050a601e:/home/git/gitlab# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@92ca050a601e:/home/git/gitlab# nginx -s reload
root@92ca050a601e:/home/git/gitlab#
再次git push
上传成功
网友评论