![](/img/trans.png)
[英]Git push failing HTTP 500 curl 22 The requested URL returned error: 500 Internal Server Error
[英]Nginx git server returns error 500
我正在尝试为裸露的git存储库设置一个nginx远程服务器(带有ssl),但是尝试从git bash(Windows 7计算机)进行git clone https://my.domain.com/repo.git
时遇到error 500
。
我当前的配置如下所示。
Nginx服务器配置:
server {
listen: 80;
server_name my.domain.com;
# Redirect all non-HTTPS traffic to the HTTPS version
return 301 https://my.domain.com;
}
server {
listen 443 ssl;
server_name my.domain.com;
root /var/www/git;
index index.html;
ssl_certificate /etc/nginx/ssl/nxing.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
access_log /var/www/git/git.access.log;
error_log /var/www/git/git.error.log;
auth_basic "Git authentication required";
auth_basic_user_file /etc/nginx/users_git;
location / {
client_max_body_size 0;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT /repo.git;
fastcgi_param PATH_INFO $1;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
}
我已咨询此资源以获取有关设置fcgiwrap的帮助: http : //knowledgebase.cc/zh/software-en/linux-en/how-to-install-fcgiwrap-to-serving-cgiperl-scripts-in- nginx的/
运行git clone http://my.domain.com/repo.git
收到的确切错误是:
克隆为'repo'...致命:无法访问' http://my.domain.com/repo.git ':请求的URL返回错误:500
这是URL访问日志的摘录:
1xx.xxx.xxx.xx--[06 / May / 2015:17:29:02 +0200]“ GET / HTTP / 1.1” 500 5“-”“ git / 1.9.5.msysgit.1”
URL的错误日志为空。
我已经经历了每个步骤,并详细介绍了本文中描述的另一个人: https : //superuser.com/questions/719949/centos-5-nginx-git-http-backend,但到目前为止我没有成功。
更新1
我尝试在nginx服务器配置的位置设置中注释掉fastgci参数,并指定位置网址本身,导致
location /repo.git {
client_max_body_size 0;
[...] commented fastcgi params [...]
}
现在的结果是,当我尝试git clone http://my.domain.com/repo.git
我在git bash中得到以下输出:
克隆到“回购”中...
“ http://my.domain.com ”的用户名:git
“ http://git@my.domain.com ”的密码:...
致命: http : //my.domain.com/repo.git/info/refs无效:这是git存储库吗?
但是我可以在浏览器中同时访问http://my.domain.com
和http://my.domain.com/repo.git
更新#2
我在以下网站上发现了战利品: http://weininger.net/configuration-of-nginx-for-gitweb-and-git-http-backend.html
: http://weininger.net/configuration-of-nginx-for-gitweb-and-git-http-backend.html
,这以某种方式帮助我解决了问题。
现在,我最终的Nginx服务器配置如下所示:
server {
listen 80;
server_name my.domain.com;
# Redirect all non-HTTPS traffic to the HTTPS version
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
server_name my.domain.com;
root /var/www/git;
index index.html;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
access_log /var/www/git/git.access.log;
error_log /var/www/git/git.error.log;
auth_basic "Git authentication required";
auth_basic_user_file /etc/nginx/users_git;
location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT /var/www/git;
fastcgi_param PATH_INFO $uri;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
}
这使我能够正确地进行git clone
和git pull
而没有任何错误,但是git push
会给我以下错误
计数对象:4,完成。
增量压缩最多使用4个线程。
压缩对象:100%(2/2),已完成。
写入对象:100%(3/3),312字节| 0字节/秒,完成。
总计3(增量0),重用0(增量0)
错误:解压失败:解压对象异常退出
前往http://my.domain.com/repo.git
! [远程拒绝]主机->主机(不适用(拆包错误))
错误:无法将某些引用推送到“ http://my.domain.com/repo ”
更新#3
似乎unpack failed
错误是由于权限问题引起的。 即使我执行chown -R git:git repo.git
我也无法推送到存储库。 但是执行chown -R git:nginx repo.git
解决了它。 考虑到这是fastcgi
脚本进行编写的(我想是?),我对此有所了解(反过来又由Nginx
产生)。
如果有人能更好地学习和理解这些内容,那么对这些设置为何以它们的工作方式进行一些澄清或更深入的解释将是很好的。
通过大量(重新)搜索和审判/错误解决了我的问题。 我所采取的步骤将在问题的更新中详细记录下来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.