我有一个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
文件)什么都没出现
我的设置有什么问题? 谢谢。