[英]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.