首页 > 解决方案 > Ubuntu 14.04 git https 服务于 nginx 问题

问题描述

我有我的https://git.example.com/网站来提供在 Ubuntu 14.04 LTS 上运行良好的静态文件。

/etc/nginx/sites-enabled/git.example.com配置是这样的:

location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
}
location ~ (/.*) {
        client_max_body_size 0; # Git pushes can be massive, just to make sure nginx doesn't suddenly cut the connection add this.
        auth_basic "Git Login"; # Whatever text will do.
        auth_basic_user_file "/var/www/git_htpasswd";
        include /etc/nginx/fastcgi_params; # Include the default fastcgi configs
        fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; # Tells fastcgi to pass the request to the git http backend executable
        fastcgi_param GIT_HTTP_EXPORT_ALL "";
        fastcgi_param GIT_PROJECT_ROOT /var/www/repo;
        fastcgi_param REMOTE_USER $remote_user;
        fastcgi_param PATH_INFO $1; # Takes the capture group from our location directive and gives git that.
        fastcgi_pass  unix:/var/run/fcgiwrap.socket;
}

(站点配置文件链接到sites-enabled。)

Unix套接字var/run/fcgiwrap.socket在那里。/usr/lib/git-core/git-http-backend程序在那里。

我使用以下 URL 访问存储库:

https://git.example.com/info.git

git remote show orig

错误:

fatal: unable to access 'https://git.example.com/info.git/': The requested URL returned error: 502

在服务器站点上/var/log/nginx

cat error.log

2018/12/15 23:38:15 [error] 26794#0: *8 no user/password was provided for basic authentication, client: 223.167.127.110, server: git.example.com, request: "GET /info.git/info/refs?service=git-upload-pack HTTP/1.1", host: "git.example.com"
2018/12/15 23:38:16 [error] 26794#0: *8 FastCGI sent in stderr: "Cannot execute script (/var/www/repo/info.git/info/refs)" while reading response header from upstream, client: 223.167.xxx.xxx, server: git.example.com, request: "GET /info.git/info/refs?service=git-upload-pack HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "git.example.com"

看起来/usr/lib/git-core/git-http-backend根本没有运行。我尝试用测试脚本替换这个程序:

#!/bin/sh

echo "$@" >/tmp/backend.log
set >> /tmp/backend.log

git remote show origin并从客户端运行一些命令,没有出现/tmp(无backend.log文件)

我的设置有什么问题?谢谢。

标签: gitubuntunginxhttpsfastcgi

解决方案


推荐阅读