Home > centos > centos 5 + nginx + git-http-backend

centos 5 + nginx + git-http-backend

February 21Hits:2
Advertisement

I've a CentOS 5 server at domain.fr. I'm trying to set a subdomain so that I can use it with git, "git.domain.fr".

  • My repositories are in /home/git (example /home/git/repos.git).
  • I've installed git-http-backend and nginx.
  • I've set a repository like this: cd /home/git/repos.git && git --bare init.
  • I've set my git.conf (included in nginx.conf) as below.

However, on my client shell, I get the fatal error "repository not found":

$ git clone http://git.domain.fr/repos.git 

Does anyone know what I should do? It seems so simple, I'm getting frustrated because I'm sure it's nothing...

server {      listen          80;     server_name     git.domain.fr;     root            /home/git;      location ~ /(/.*) {          include /etc/nginx/fastcgi_params;         fastcgi_param   SCRIPT_FILENAME /usr/bin/git-http-backend;         fastcgi_param   GIT_HTTP_EXPORT_ALL     true;         fastcgi_param   GIT_PROJECT_ROOT        /home/git;         fastcgi_param   PATH_INFO               $1;         fastcgi_pass unix:/var/run/fcgiwrap.socket;     } } 

EDIT #1

I've updated the file as this:

server  {      listen          80;     server_name     git.domain.fr;     root            /home/git;      access_log /var/log/httpd/git.access.log;     error_log /var/log/httpd/git.error.log;      location / {          include /etc/nginx/fastcgi_params;          fastcgi_param   SCRIPT_FILENAME /usr/bin/git-http-backend;         fastcgi_param   GIT_HTTP_EXPORT_ALL     true;         fastcgi_param   GIT_PROJECT_ROOT        /home/git;         fastcgi_param   PATH_INFO               $uri;          fastcgi_pass unix:/usr/local/src/fcgiwrap/systemd/fcgiwrap.socket;     } } 

I also checked the socket location and gave it to nginx:nginx, but I'm now getting an "Error 500".

$ git clone git.domain.fr/repos.git Cloning into 'repos'... fatal: unable to access 'git.domain.fr/repos.git/': The requested URL returned error: 500 

fcgi wrap is running:

$ netstat -anp | grep cgi unix  2      [ ACC ]     STREAM     LISTENING     1510861 24878/fcgiwrap      /usr/local/src/fcgiwrap/systemd/fcgiwrap.socket 

It has the correct permissions:

$ ls -lia /usr/local/src/fcgiwrap/systemd/fcgiwrap.socket 3067341 srwxrwxrwx 1 nginx nginx 0 févr. 22 23:51 /usr/local/src/fcgiwrap/systemd/fcgiwrap.socket 

git.error.log is empty, but git.access.log contains:

1**.***.***.*** - - [23/Feb/2014:13:02:17 +0100] "GET /repos.git/info/refs?service=git-upload-pack HTTP/1.1" 500 5 "-" "git/1.8.4" 

EDIT #2

Problem almost solved : I just restarted my server for some reasons, then git pull worked.

Now, I am getting a 403 error when I push.

Push :

$ GIT_CURL_VERBOSE=1 git push origin master * Adding handle: conn: 0x7fe329811800 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x7fe329811800) send_pipe: 1, recv_pipe: 0 * About to connect() to git.domain.fr port 80 (#0) *   Trying 108.162.199.22... * Connected to git.domain.fr (108.162.199.22) port 80 (#0) > GET /repos.git/info/refs?service=git-receive-pack HTTP/1.1 User-Agent: git/1.8.4 Host: git.domain.fr Accept: */* Accept-Encoding: gzip Pragma: no-cache  < HTTP/1.1 403 Forbidden * Server cloudflare-nginx is not blacklisted < Server: cloudflare-nginx < Date: Sun, 23 Feb 2014 18:20:59 GMT < Content-Type: application/octet-stream < Transfer-Encoding: chunked < Connection: keep-alive < Set-Cookie: __cfduid=dc7d61cac342494e2b1307f88f8bf440f1393179659791; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.domain.fr; HttpOnly < Expires: Fri, 01 Jan 1980 00:00:00 GMT < Pragma: no-cache < Cache-Control: no-cache, max-age=0, must-revalidate < Expires: Fri, 01 Jan 1980 00:00:00 GMT < Pragma: no-cache < Cache-Control: no-cache, max-age=0, must-revalidate < CF-RAY: 1015eee9b29a091a-CDG <  * Connection #0 to host git.domain.fr left intact fatal: unable to access 'http://git.domain.fr/repos.git/': The requested URL returned error: 403 

Pull :

$ GIT_CURL_VERBOSE=1 git pull origin master * Adding handle: conn: 0x7fb11b811800 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x7fb11b811800) send_pipe: 1, recv_pipe: 0 * About to connect() to git.domain.fr port 80 (#0) *   Trying 108.162.198.22... * Connected to git.domain.fr (108.162.198.22) port 80 (#0) > GET /repos.git/info/refs?service=git-upload-pack HTTP/1.1 User-Agent: git/1.8.4 Host: git.domain.fr Accept: */* Accept-Encoding: gzip Pragma: no-cache  < HTTP/1.1 200 OK * Server cloudflare-nginx is not blacklisted < Server: cloudflare-nginx < Date: Sun, 23 Feb 2014 18:25:33 GMT < Content-Type: application/x-git-upload-pack-advertisement < Transfer-Encoding: chunked < Connection: keep-alive < Set-Cookie: __cfduid=d75ab90529a399f012383cdee482bc7ed1393179933224; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.domain.fr; HttpOnly < Expires: Fri, 01 Jan 1980 00:00:00 GMT < Pragma: no-cache < Cache-Control: no-cache, max-age=0, must-revalidate < CF-RAY: 1015f596a8700914-CDG <  * Connection #0 to host git.domain.fr left intact From http://git.domain.fr/repos  * branch            master     -> FETCH_HEAD Already up-to-date. 

Log (error.log is empty) :

$ tail -f /var/log/httpd/git.access.log  1**.***.***.*** - - [23/Feb/2014:19:20:59 +0100] "GET /repos.git/info/refs?service=git-receive-pack HTTP/1.1" 403 5 "-" "git/1.8.4" 1**.***.***.*** - - [23/Feb/2014:19:25:33 +0100] "GET /repos.git/info/refs?service=git-upload-pack HTTP/1.1" 200 294 "-" "git/1.8.4" 

I checked the rights and owners. What can I do ? Any idea ?

EDIT #3

SUCCESS !

Git push gets a 403 errors when you use it without authentication. I just had to set nginx so that it asks for a user/password :

server  {      listen          80;         server_name     git.domain.fr;         root            /home/git;          access_log /var/log/httpd/git.access.log;         error_log /var/log/httpd/git.error.log;          auth_basic          "Accès restreint";         auth_basic_user_file    /home/domain.fr/git_access;          location / {                  include /etc/nginx/fastcgi_params;                  fastcgi_param   SCRIPT_FILENAME         /usr/bin/git-http-backend;                 fastcgi_param   GIT_HTTP_EXPORT_ALL     true;                 fastcgi_param   GIT_PROJECT_ROOT        /home/git;                 fastcgi_param   PATH_INFO               $uri;                 fastcgi_param   REMOTE_USER         $remote_user;                  fastcgi_pass unix:/usr/local/src/fcgiwrap/systemd/fcgiwrap.socket;         } } 

You should also check that your repository belongs to git:git :

chmod -R g+ws repos.git chgrp -R git repos.git 

Everything's fine now.

Thanks for your help !

Answers

Your location match URIs starting with two slashes which is impossible with default nginx configuration. Also there is no need to have regexp location, if you want proxy all requests. This one should work for you:

location / {

    include /etc/nginx/fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME /usr/bin/git-http-backend;
    fastcgi_param   GIT_HTTP_EXPORT_ALL     true;
    fastcgi_param   GIT_PROJECT_ROOT        /home/git;
    fastcgi_param   PATH_INFO               $uri;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
}

Tags:git, nginx, centos

Related Articles

  • centos 5 + nginx + git-http-backendFebruary 21

    I've a CentOS 5 server at domain.fr. I'm trying to set a subdomain so that I can use it with git, "git.domain.fr". My repositories are in /home/git (example /home/git/repos.git). I've installed git-http-backend and nginx. I've set a repository l

  • Howto Nginx + git-http-backend + fcgiwrap (Debian Squeeze)November 23

    I am trying to setup git-http-backend with Nginx but after 24 hours wasting time and reading everything I could I think this config should work but doesn't. server { listen 80; server_name mydevserver; access_log /var/log/nginx/dev.access.log; error_

  • Configuration of nginx for git-http-backend on debian(-based systems)November 27

    I'm having trouble to get git-http-backend working using an nginx server on my Ubuntu 13.04 machine. Tried it with Debian 7 before but with similar results. Basically I followed http://weininger.net/configuration-of-nginx-for-gitweb-and-git-http-back

  • Configuration of git-http-backend with Nginx (returning PROPFIND 405)February 22

    I'm trying to configure git-http-backend over nginx and having some troubles. The actual result is that I'm getting a 405 error for the PROPFIND request: 192.168.1.45 - - [22/Feb/2015:16:50:46 +0100] "GET /lw/bla.git/info/refs?service=git-receive-pac

  • Unexpected error with git-http-backend over Nginx and fcgiwrapJuly 3

    Original question I'm trying to setup a git repo for remote access through HTTP. Thing is, even a simple git clone is not working. This is the error message: /var/log/nginx/error.log 2015/07/03 11:18:05 [error] 13323#0: *1 open() "/usr/share/nginx/ht

  • Nginx and git-http-backend - 405 errorSeptember 23

    I'm trying to configure git-http-backend over nginx, but without success. My configuration is: mkdir -p /var/git/repo1 cd /var/git/repo1 git init --bare git update-server-info chown -R nginx:nginx /var/git File /etc/nginx/conf.d/default.conf: server

  • git-http-backend with apache2.4 Centos 7January 29

    I try to set up a Git-server on my apache server but it dont work! I got the following git.conf SetEnv GIT_PROJECT_ROOT /var/www/html/git/project1 SetEnv GIT_HTTP_EXPORT_ALL ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/ <Directory "/va

  • nginx git folder requestJanuary 10

    Im using nginx and git-web and it works great. I access my site using www.mydomain.org to pull up gitweb. Here is my config file: server { listen 80 default_server; listen [::]:80 default_server; server_name www.mydomain.org; return 301 https://$serv

  • What are the steps to setup git-http-backend w/ Apache on Windows?March 14

    I would like setup a Git server using the "Smart-HTTP" approach. However, I'm having difficulties getting it to work in Windows, and I'm new to Apache. My httpd.conf, in part: SetEnv GIT_PROJECT_ROOT "d:/repositories" SetEnv GIT_HTTP_E

  • Ubuntu, Git (git-http-backend) and ApacheNovember 23

    I am trying to setup a repository server based on git combine with its git-http-backend and apache. My problem? I can clone perfectly, but when i try ti push, i hit a wall $ git push origin master * Couldn't find host git.local in the .netrc file; us

  • Is there any difference between git-http-backend and simple dav repository hosting setups?March 2

    In some searches, I've found two slightly different approaches on how to serve a git repository over http. The first one is using only DAV. The second one uses DAV and git-http-backend. Is there any difference between the above approaches? ----------

  • git http-backend show info when accessing per browserNovember 5

    I'm currently hosting my own git-repos for my private projects. For this, I use Apache and the standard git http-backend. Now, a repo can be accessed under an URL like this: http://vcs.myserver.lc/git/Repo.git With this URL, I can push, fetch and clo

  • Git push over http (using git-http-backend) and Apache is not workingMay 20

    I have desperately been trying to get push for git working through the "smart-http" mode using git-http-backend. However after many hours of testing and troubleshooting, I am still left with error: Cannot access URL http://localhost/git/hello.gi

  • Apache looking for wrong directory in git-http-backend configurationFebruary 4

    I wouldn't be posting here unless I've run out of options. Be forewarned, I could be making a very simple rookie mistake. I'm trying to set up the git-http-backend on Ubuntu Server 12.04. I've gone through all the tutorials and configurations I've fo

  • git-http-backend, ro for all, write requiring password? (with lighttpd)April 7

    I'd like to offer up read-only access to my GIT repos for everyone (i.e. no username/password required), but require authentication for writing. The git-http-backend man page suggests this is possible by matching against the location ^/git/.*/git-rec

  • git-http-backend and LDAP authentication, push error: requested URL returned error: 401 Authorization RequiredDecember 11

    My setup OS: debian git: v 1.7.10 apache (with suexec mode enabled) configuration with git-http-backend and LDAP authorization to git repos which works for clone operations, but not working for push and that's the problem. I use HTTPS as communicatio

  • How to suspend Nginx requests during backend upgradesDecember 26

    I'd like to have Nginx suspend (hold) http requests for short periods of time, while I upgrade or restart the backend service, do a database migration, or some other administrative task, without causing errors to the end users. Basically I'd like to

  • How to install centos,nginx ,mongodb?February 6

    I need to install nginx, mongodb, eclipse, oraclejava 8 in centos OS. Which centOS is good for working this? One more thing: I am new in linux give me a link or sample doc for how to install centos,nginx,mongodb,oraclejava 8 in centos I prefer centos

  • centos: nginx + thin webserver, incoming connections not allowedMarch 2

    I setup a fresh CentOS 5 install, compile nginx from scratch and am using thin as the rails server. If I visit the ip adress on the LAN: (for example) 1.2.3.4 I get the website not found error. However, I can ssh into the machine. If I use links to v

  • Daemonizing tool for Gunicorn Centos Nginx and DjangoSeptember 29

    I have set up a basic centos server and through that tested certain technologies. Currently I am running django-1.3, Nginx with FastCGI - works like a charm I have noticed that as soon as my latest commits are pulled and Nginx restarted, they don't t

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.442 s.