【问题标题】:Fail to push changes to git repository via http proxied by Nginx无法通过 Nginx 代理的 http 将更改推送到 git 存储库
【发布时间】:2017-02-26 22:10:07
【问题描述】:

我不熟悉通过 http 使用 Nginx(不是 Apache)设置 Git 存储库 我找到了this guide,这似乎是一个非常简单的解决方案。

我能够创建一个存储库并使用git clone 命令,但是当我尝试将更改推送到远程存储库时,我收到了来自客户端的以下消息

#git push origin master
XML error: not well-formed (invalid token)
error: no DAV locking support on http://192.168.80.128/git/it-knowledge.git/
fatal: git-http-push failed

谁能帮我弄清楚我犯了什么错误? 关于 DAV 锁定支持,我搜索并看到一些关于 Apache 的 DAV 锁定文件的线程,NginX 上是否有任何等效配置以便成功推送更改?

下面是我的git路径的nginx配置文件,我的nginx已经安装了--with-http_dav_module选项

server {
    listen       80;
    server_name  192.168.80.128;
    client_body_temp_path /tmp/client_temp;
    location ~ /git(/.*) {
        dav_methods PUT DELETE MKCOL COPY MOVE;
        create_full_put_path  on;
        dav_access  user:rw group:rw all:rw;
        autoindex  on;
        client_max_body_size  10G;
        fastcgi_pass  localhost:9000;
        include       fastcgi_params;
        fastcgi_param SCRIPT_FILENAME     /usr/libexec/git-core/git-http-backend;
        fastcgi_param GIT_HTTP_EXPORT_ALL "";
        fastcgi_param GIT_PROJECT_ROOT    /srv/git;
        fastcgi_param PATH_INFO           $1;
    }
}

【问题讨论】:

    标签: git nginx webdav


    【解决方案1】:

    该指南指的是2010 article
    类似的配置是in this gist

    location ~ /git(/.*) {
        # Set chunks to unlimited, as the body's can be huge
        client_max_body_size            0;
    
        fastcgi_param   SCRIPT_FILENAME     /usr/lib/git-core/git-http-backend;
        include     fastcgi_params;
        fastcgi_param   GIT_HTTP_EXPORT_ALL "";
        fastcgi_param   GIT_PROJECT_ROOT    /git;
        fastcgi_param   PATH_INFO       $1;
    
        # Forward REMOTE_USER as we want to know when we are authenticated
        fastcgi_param   REMOTE_USER     $remote_user;
        fastcgi_pass    unix:/var/run/fcgiwrap.socket;
    }
    

    确保您的存储库位于 ~ 中,并且 /usr/lib/git-core/git-http-backend 确实存在(具有足够新的 Git 版本)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-27
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 1970-01-01
      • 2011-07-13
      • 1970-01-01
      相关资源
      最近更新 更多