git - NGINX fastcgi 代理上使用 git-http-backend 的多个同时请求
问题描述
我git-http-backend
通过 nginx fastcgi 代理服务 git repos。nginx 配置如下所示:
server {
listen 443 ssl;
server_name git.example.com;
auth_basic "Git Access";
auth_basic_user_file /etc/nginx/.htpasswd_git;
error_log /var/log/nginx-git-error.log;
access_log /var/log/nginx-git-access.log;
client_max_body_size 0;
root /var/git/;
location ~ /git(/.*) {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param GIT_PROJECT_ROOT /var/git;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $1;
fastcgi_read_timeout 600;
}
}
从测试来看,如果一次有多个请求,代理将失败(代码为 504),并且一些谷歌搜索似乎证实了我的怀疑,即git-http-backend
不能支持多个请求。
如何设置它以便可以一次向 git repo 发出多个请求?
解决方案
我最近也遇到了同样的情况,很快在github上找到了这个脚本
它为每个新的 http 请求生成一个新的 git-http-backend 实例。编译它(需要安装go语言)通过
go build git-http-multi-backend.go
并运行它
./git-http-multi-backend -r /Path/To/Repos
这将使它在 :80 上侦听(可以更改端口)。您现在只需将您的 nginx 配置更改为类似
location ~ /git(/.*) {
proxy_pass http://localhost:80;
}
我承认,这不是最优雅的解决方案,因为完全可以通过摆弄 nginx 配置来实现相同的效果。git-http-multi-backend 工具的作者甚至谈到了它,但缺乏任何具体的实现示例。
推荐阅读
- java - 连接到 AxonServer 节点 [192.168.99.100:8124] 失败:内部:恐慌!这是一个错误
- css - 不同的订单项目和布局与 css3 通过分辨率与相同的 html
- java - 如何使用 Java 在 MSSQL 中以“2016-01-01T19:33:15-05:00”格式插入日期时间?
- javascript - 如何用鼠标中键在后台打开新标签?
- python - 我正在尝试在 excel 列上设置条件,以使用 python openpyxl 从一张表获取一些数据到另一张 excel 表
- python - 连接 MySQL 时出现“KeyError: 0” (get_default_isolation_level)
- reactjs - 如果错误仍然存在,如何防止提交此表单?
- c - 如何标记文件内容?
- wordpress - 当它是顶级类别的一部分时,我想显示一条消息
- java - 在单元测试中注入不可变的配置属性