因业务需求,需要把内网gitlab仓库的地址对外网访问,在gitlab前端配置了一个nginx代理服务器,来实现需求,可以在git clone的时候报error: RPC failed错误

[root@Server_yd]# git clone  http://username:password@gitlab.linzhongfengniao.com/ElectronicAPI.git
Initialized empty Git repository in /tmp/ElectronicVisaAPI/.git/
remote: Counting objects: , done.
remote: Compressing objects: % (/), done.
error: RPC failed; result=, HTTP code =
Receiving objects: % (/), 12.00 KiB | KiB/s
^C

经查询大致的意思就是内容过大,需要配置http.postBuffer,在服务器端配置后,依然无效,使用没有经过nginx代理端的地址测试正常。

git config --global http.postBuffer 

由此判断问题出现在了nginx代理服务器,下载大文件超时。

nginx代理前端用户请求下载文件, nginx代理会先从后端nginx拿到文件并缓存到本地,然后响应给客户端,其中与proxy buffer相关的配置项如下:

proxy_buffer_size 512k;
proxy_buffers 512k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 512k;

由此可知, buffer缓冲区最大可以缓冲2.5M的数据,然后就开始刷写磁盘,如果磁盘无法写入,数据丢失。这也是为什么前端下载部分数据,即下载不动的原因。

原因分析:
 1、代理服务器报告:上游过早的关闭连接,好像问题出在被代理服务器;而被代理服务器则抱怨:上游服务器超时。那么一个很合理的推论是:代理服务器很长时间没向被代理服务器请求数据,被代理服务器认为代理服务器已经掉线或完成任务,于是主动断开连接,代理服务器发现需要数据,再连接时,已经连接不上了。
 2、正常的流程应该是:只要客户端一直下载,“客户机->代理服务器->被代理服务器”,这一连串的数据流不会中断,也就不会出现超时。
 3、出现超时只能有一种情况:代理服务器缓存了大文件。
 4、代理服务器接到下载请求,向被代理服务器请求数据,由于两个服务器之间网速快,所以代理服务器请求速度要远大于向客户端发送的速度,这就导致一下正常的代理方式:代理服务器要缓存数据。
 5、但是两个服务器之间的速度实在是太快了,缓存1G数据也就是分分钟的事情,而客户端需要慢慢下载,可能需要十几、甚至几十分钟。代理服务器和被代理服务器这段时间内没有什么事可干,与是两端静默的时间一长,超过了timeout的时间(一般是60s),被代理服务器就认为代理服务器掉线。
 
解决方案:
1)将代理服务器缓存设置更大,可以直接缓存整个文件,跟上面的解决一样
2)禁用代理服务器缓存:

 proxy_redirect default;
proxy_buffering off;

3)设置更长的超时时间

proxy_send_timeout ; #后端服务器数据回传时间(代理发送超时)
proxy_read_timeout ; #连接成功后,后端服务器响应时间(代理接收超时)

代理配置如下:

server {
listen ;
server_name gitlab.linzhongfengniao.com;
access_log /var/log/nginx/gitlab.linzhongfengniao.log main;
set $web_url $host;
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot")
{
return ;
}
location / {
proxy_pass http://192.168.3.100;
include /etc/nginx/conf.d/deny.conf;
proxy_redirect default;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $domain default;
}
}

git clone的时候报error: RPC failed; result=18错误的更多相关文章

  1. (转)git clone: error: RPC failed; result=18, HTTP code = 200 解决办法

    git clone: error: RPC failed; result=18, HTTP code = 200 解决办法 分类: git2013-09-01 17:03 10753人阅读 评论(2) ...

  2. cocoaPods安装成功终端代码(期间报error: RPC failed; result=56, HTTP code = 200)

    Last login: Sat Oct 15 23:30:24 on ttys002 Sivek_lindeMacBook-Pro:~ Sivek_lin$ sudo gem update --sys ...

  3. git clone 新项目时,报error: RPC failed; curl 18 transfer closed with outstanding read data remaining

    error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal: The remote en ...

  4. 对于在git上面拉代码报"error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054"解决方法

    主要原因是安全设置的问题: 首先执行git config http.sslVerify "false"   若出现下列错误 git config http.sslVerify &q ...

  5. git bash: error: RPC failed; result = 18, HTP code = 200B

    git config --global http.postBuffer 2428800 如果还是失败,说明buffer不够大,继续增加buff git config --global http.pos ...

  6. pod setup》error: RPC failed; result=18, HTTP code = 200

    Try reducing the postBuffer size in the remote repository config. Follow the steps below Go to remot ...

  7. git clone报错error: RPC failed; curl 18 transfer closed with outstanding read data remaining

    具体错误信息如下图: error: RPC failed; curl 18 transfer closed with outstanding read data remaining    fatal: ...

  8. 解决git报错:error: RPC failed; curl 18 transfer closed with outstanding read data remaining 的方法

    报错信息: error: RPC failed; curl 18 transfer closed with outstanding read data remainingfatal: the remo ...

  9. git clone error: RPC failed; result=22, HTTP code = 502

    http://www.jianshu.com/p/645d3fe4e028 git克隆的工程太大用https的方式会有如下问题 hbl:tmp hubert$ git clone https://gi ...

随机推荐

  1. CF Gym 100637B Lunch(拆分子问题)

    题意:在一条狭窄的沼泽上有一列数量为n的连续荷叶,编号为1-n.有一只蛤,在边s号荷叶上,其他荷叶上苍蝇,哈可以跳到相邻的荷叶上,或者越过一片荷叶,跳完以后原来的荷叶会沉,目标是f荷叶,在跳到f荷叶之 ...

  2. BZOJ 1001 狼抓兔子 平面图的最小割

    题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1001 题目大意: 见链接 思路: 求最小割,平面图的最小割等价于对偶图的最短路 直接建 ...

  3. eclipse 自动生成get/set方法

    Shift+Alt+S 会弹出一个对话框 选择Generate Getters and Setters

  4. [19/05/02-星期四] GOF23_行为型模式(状态模式、观察者模式、备忘录模式)

    一.状态模式 [状态接口] /*** * 房间"状态"接口 */ package cn.sxt.state; public interface State { void handl ...

  5. windows下使用Git

    如何在windows下使用Git? 通过这里下载Git bash,你就可以像在Linux命令行一样操作git工具. 进入Git bash环境,默认是在当前用户路径下. 在Linux下,我们有根目录,在 ...

  6. windows下更新npm的命令实现

    Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force npm install -g npm-windows-upgrade npm-wi ...

  7. SVN篇

    启动SVN : svnserve -d -r svn 查看进程: ps -ef | grep svmserve -------------------------------------------- ...

  8. docker安装后启动不了 解决方法

    第一种情况: 可能是你的selinux没有disabled,导致了守护docker的deamon进程启动不了 查看系统日志如果发现下列信息: May 7 12:34:14 localhost dock ...

  9. Dynamic Rankings—带单点修改的主席树

    这道题应该是很不错的板子了\(\mathcal{\color{cyan}{Link}}\) \(\mathcal{\color{red}{Description}}\) 给定一个序列,有两种操作.一是 ...

  10. 错误:maximum number of expressions in a list is 1000

    某一日发现这么如下这么一个错误  --> maximum number of expressions in a list is 1000 原因:因为SQL语句中用到了IN字句,而IN中的元素个数 ...