NGINX + Git 推送 = 403

NGINX + Git 推送 = 403

我在远程机器上有 Git repo,配置了 NGINX + uWSGI。

Nginx 编译使用:

# nginx -V
nginx version: nginx/1.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
configure arguments: --with-http_dav_module --add-module=nginx-dav-ext-module-master --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --user=nginx --group=nginx

Nginx 配置:

server {
    listen       80;
    server_name git.domain.local;
    root /var/gitrepo;

    access_log /var/log/nginx/git_access.log;
    error_log /var/log/nginx/git_error.log;

    location / {

        auth_basic "Password-protected Area";
        auth_basic_user_file /var/gitrepo/.htpasswd;

        include uwsgi_params;
        uwsgi_pass  127.0.0.1:9090;
        uwsgi_modifier1 9;
        uwsgi_param GIT_HTTP_EXPORT_ALL "";
        uwsgi_param GIT_PROJECT_ROOT    /var/gitrepo;
        uwsgi_param PATH_INFO           $uri;

        dav_methods PUT DELETE MKCOL COPY MOVE;
        dav_ext_methods PROPFIND OPTIONS;
    }
}

我可以克隆 repo:

$ git clone http://user:[email protected]/local.git
Cloning into 'local'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

但-不能push

$ touch file

$ git add .

$ git commit -m 'sdc'
[master (root-commit) 442fda3] 'sdc'
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file

$ git push http://user:[email protected]/local.git master
fatal: unable to access 'http://user:[email protected]/local.git/': The requested URL returned error: 403

Nginx 仅说:

192.168.1.146 - - [08/Mar/2015:18:48:29 +0200] "GET /local.git/info/refs?service=git-receive-pack HTTP/1.1" 401 194 "-" "git/1.9.5.msysgit.0"
192.168.1.146 - user [08/Mar/2015:18:48:29 +0200] "GET /local.git/info/refs?service=git-receive-pack HTTP/1.1" 403 5 "-" "git/1.9.5.msysgit.0"

本地 Git 配置:

$ git config --list
core.symlinks=false
core.autocrlf=input
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
[email protected]
user.name=Your Name
gui.recentrepo=C:/Users/setevoy/Documents/GIT repos/gg
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=http://user:[email protected]/local.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

我很惊讶,因为相同的配置在我办公室的其他主机上运行良好......我在这里做错了什么?

答案1

$ git clone http://user:[email protected]/local.git
Cloning into 'local'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

根据上述内容,您似乎正在克隆一个空的存储库,这不允许您推送。确保您没有克隆空的存储库。

但如果这是初始提交:

git push --set-upstream origin master

然后推。

相关内容