无法通过Nginx代理的http将更改推送到git存储库

时间:2017-02-26 12:53:01

标签: git nginx webdav

我是新手,通过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;
    }
}

1 个答案:

答案 0 :(得分:0)

该指南指的是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版本)