1

I have an online server (Ubuntu 17.04) that host my bare repos. I tried to set up HTTPS on this server, and I can pull but I can't push, it fails with the following error:

error: Cannot access URL https://user:passwd@myserver.com/REPO/, return code 22 fatal: git-http-push failed error: failed to push some refs to 'https://user:passwd@myserver/REPO/'

The nginx config relevant part looks like that:

# static repo files for cloning over https
location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))$ {
    client_max_body_size 0;
    auth_basic  "Restricted Area";
    auth_basic_user_file /etc/apache2/.htpasswd;
    fastcgi_param REMOTE_USER $remote_user;
    root /home/git/;
}

# requests that need to go to git-http-backend
location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
    client_max_body_size 0;
    auth_basic  "Restricted Area";
    auth_basic_user_file /etc/apache2/.htpasswd;
    root /home/git/;

    #fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_param SCRIPT_FILENAME   /usr/lib/git-core/git-http-backend;
    fastcgi_param PATH_INFO         $uri;
    fastcgi_param GIT_PROJECT_ROOT  /home/git/;
    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param REMOTE_USER $remote_user;
    include fastcgi_params;
}

In all the thread I read the problem came from the REMOTE_USER fastcgi param or the local git config that lacked user/passwd in the remote URL, but I set up that so I am clueless. Does anyone have an idea or see a problem?

EDIT: Here is my .git/config:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = https://user:passwd@myserver.com/REPO/
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    name = git
Krapow
  • 611
  • 6
  • 26

1 Answers1

0

Without reproducing your setup, are you sure that receivepack is correctly enabled, according to the documentation?

And what if you try to update your local .git/config URL like in this post (look at the comment)

lovethebomb
  • 283
  • 5
  • 12
  • I already updated my .git/config (look at the error, username is in the URL) And receivepack is by default enable for authenticated user and disabled for anonymous which is what I want – Krapow Oct 16 '17 at 14:23
  • OK, what about the nginx fastcgi_params, any chance that it overrides the params defined before? I'm not sure if `git push -v` provides useful info when using HTTP instead of SSH, but could give it a try. I'll try to see if I can reproduce your setup. – lovethebomb Oct 16 '17 at 14:35
  • Also just in case, can you update your question and add your repo `.git/config`? – lovethebomb Oct 16 '17 at 14:39
  • I edited to add my .git/config. Also the fastcgi_params is not override, the only block after the two I copied is "location ~ \.php$" – Krapow Oct 16 '17 at 14:52
  • Thanks! I've reproduced your setup and I've to admit that I have the same issue, no matter what... When increasing the error log level nginx, I receive a 405 error, on a PROPFIND method, which would means that the request is probably not passed to `git-http-backend`... Still investigating... – lovethebomb Oct 16 '17 at 17:26