Git推送在写入对象时冻结,并给出504错误



问题

Git在HTTPS上为81 kB的repo写入对象时挂起(不允许SSH(。来自Nginx的access.log的具体错误消息如下:

POST /Hello-World/.git/git-receive-pack HTTP/1.1" 504 183 "-" "git/2.28.0.windows.1"

背景

我托管Nginx和Git服务器,它们位于安装的Debian映像中。需要注意的是:我的所有网站文件的www都是以只读方式单独安装的。我的Git根文件夹也在www(即www/git(中。

sudo mount -o loop,offset=1 raspbian-stretch-lite.img /mnt/
sudo mount --bind www/ /mnt/usr/share/nginx/www/
sudo mount -o bind,remount,ro /mnt/usr/share/nginx/www

我的Nginx conf如下:

server {
listen 443 ssl;
server_name git.domain.com;
ssl_certificate fullchain.pem;
ssl_certificate_key privkey.pem;
# fast clone static files
location ~ .git/objects/(?:[0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(?:pack|idx))$ {
root /usr/share/nginx/www/git;
limit_except GET HEAD {
allow all;
}
}
location ~ ^.*.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack) {
root /usr/share/nginx/www/git;
auth_basic "Restricted";
auth_basic_user_file /usr/share/nginx/www/auth;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT $realpath_root;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $uri;
fastcgi_param unix:/var/fcgiwrap.socket;
}
location /gitweb.cgi {
root /usr/share/nginx/www/gitweb;
include fastcgi_params:
gzip off;
fastcgi_param SCRIPT_NAME $uri:
fastcgi_param GITWEB_CONFIG $realpath_root/gitweb.conf;
fastcgi_pass unix:/var/fcgiwrap.socket;
}
location / {
root /usr/share/nginx/www/gitweb;
index gitweb.cgi;
}
}

如果我从浏览器访问https://git.domain.com,我会得到一个GitwebGUI。我用git clone https://git.domain.com/Hello-World/.git克隆,一切都很好。但当我尝试使用git push进行推送时,它在编写对象步骤时挂起,最终导致网关超时错误。有趣的是,每次发生这种情况时,https://git.domain.comGit网页和Git后端都会关闭,迫使我终止并重新启动fcgiwrap进程。

我的猜测

我试过git config --global http.postBuffer 524288000,但没有用。由于我正在进行身份验证(通过键入用户名和密码(,应该允许git-receive-pack,对吧?

我认为这与git文件夹没有写入权限有关?也许我的Nginx配置的正则表达式不正确?

编辑:

通常,Git中的错误会进入stderr,stderr通常由web服务器写入日志。你的系统上有这样的日志吗?如果有,它包含什么?

我在客户端的命令提示符中得到的错误如下:

(base) C:UserspairwiseseqHello-World>git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 258 bytes | 258.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
Everything up-to-date

同样来自Nginx的error.log:

*9 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 123.456.7.890, server: git.domain.com, request: "POST /Hello-World/.git/git-receive-pack HTTP/1.1", upstream: "fastcgi://unix:/var/fcgiwrap.socket", host: "git.domain.com"

fcgiwrap过程的strace

read(3, "11110111410417fQUERY_STRING164REQUEST_METHODPOSTf&CONTENT_TYPEapplication/x-git-receive-pack-request163CONTENT_LENGTH452v"SCRIPT_NAME/Hello-World/.git/git-receive-packv"REQUEST_URI/Hello-World/.git/git-receive-packf"DOCUMENT_URI/Hello-World/.git/git-receive-packr30DOCUMENT_ROOT/usr/share/nginx/www/git1710SERVER_PROTOCOLHTTP/1.1165REQUEST_SCHEMEhttps52HTTPSon217GATEWAY_INTERFACECGI/1.117fSERVER_SOFTWAREnginx/1.10.3vrREMOTE_ADDR123.456.7.890v5REMOTE_PORT39118vfSERVER_ADDR123.456.7.12v3SERVER_PORT443v20SERVER_NAMEgit.domain.com173REDIRECT_STATUS20017"SCRIPT_FILENAME/usr/lib/git-core/git-http-backend23GIT_HTTP_EXPORT_ALL2030GIT_PROJECT_ROOT/usr/share/nginx/www/gitv10REMOTE_USERusernamet"PATH_INFO/Hello-World/.git/git-receive-pack244HTTP_ACCEPT_ENCODINGgzipv10HTTP_PRAGMAno-cache1731HTTP_USER_AGENTJGit/5.1.2.201810061102-r22*HTTP_AUTHORIZATIONBasic cGc5eno0c2g6WWw5V1RpdnVrWlE2QTRNRw==21&HTTP_CONTENT_TYPEapplication/x-git-receive-pack-requestv%HTTP_ACCEPTapplication/x-git-receive-pack-result254HTTP_CONTENT_ENCODINGgzip233HTTP_CONTENT_LENGTH452t20HTTP_HOSTgit.domain.com17nHTTP_CONNECTIONKeep-Alive14115113044372131012551R37600b97fd1a60b01f91b314f59955a4e4d4e80d8edf11d f1a5d26dcb87f31b127cd397894aae43f86f362c refs/heads/masterreport-status delete-refs ofs-delta side-band-64k agent=JGit/5.1.2.201810061102-r0000PACK23234fx234225313301r3020f@321{2463102225354&v32t!63403064I3541016220*r36724721430034535276364m252zT&26222363262322244J252672252651"K<273f255215334^246~314247.X30*`317X3306N923225250Q242n 233JG24W16{216351m234\~33636307354245351r/273215}tW217fkft3373510300265361~277314364337317}1q~<[2422x234340031Q10rut361ue210233301z.Q341Ks234307375O3112335355N241:257246v211=x234363H315311311WHLO314314S3442 d4@4{334"301Rv30337271275n2033349{D255S;93012472002551151", 8192) = 1584
write(5, "372131012551R37600b97fd1a60b01f91b314f59955a4e4d4e80d8edf11d f1a5d26dcb87f31b127cd397894aae43f86f362c refs/heads/masterreport-status delete-refs ofs-delta side-band-64k agent=JGit/5.1.2.201810061102-r0000PACK23234fx234225313301r3020f@321{2463102225354&v32t!63403064I3541016220*r36724721430034535276364m252zT&26222363262322244J252672252651"K<273f255215334^246~314247.X30*`317X3306N923225250Q242n 233JG24W16{216351m234\~33636307354245351r/273215}tW217fkft3373510300265361~277314364337317}1q~<[2422x234340031Q10rut361ue210233301z.Q341Ks234307375O3112335355N241:257246v211=x234363H315311311WHLO314314S3442 d4@4{334"301Rv30337271275n2033349{D255S;93012472002551", 452) = 452
read(6, "Expires: Fri, 01 Jan 1980 00:00:00 GMTrnPragma: no-cachernCache-Control: no-cache, max-age=0, must-revalidaternContent-Type: application/x-git-receive-pack-resultrnrn", 4096) = 165

之后,fcgiwrap就完全挂起了。在这一点上,我既不能clone也不能push,并且必须生成一个新的fcgiwrap进程。

你试过这里的答案吗?

git config --add remote.origin.proxy ""

这里还有一个答案,人们抱怨504个错误;"推";。

一开始推送时我也出现了HTTP 504错误(网关超时(;对我来说,这是由权限问题引起的:fcgiwrap作为用户www数据运行,但git存储库目录归另一个用户所有。

相关内容

  • 没有找到相关文章

最新更新