1

Here the full story: To make team project more easy to manage, view and follow, I had to build a project to setup a complete repository to centralize all of our differents projects.

For this, I planned to put on a dedicated (VM) Debian server:

  • A CVS (git)
  • A web server (Nginx)
    • Containing a frontend for git (Gitlist)
    • A Bugtracker that can work with LDAP (mantis)
  • A MTA for giving the possibility to the bugtracker to send mails

Everything is more or less set and functional but Gitlist continue to give me somes difficulties and even if I have found some answers, none of them have worked until now, that is why I am here now.

Now the details of the problem:

my git repositories are in /home/git/repositories/ (set with chmod 744 for Gitlist to access it)

I can init (bare) projects, push and pull from them, etc..., everything seem ok for this part

Nginx is set to serve the content of /var/www/html/ and Gitlist is in the directory /var/www/html/depot/

The Gitlist config.ini have this content:

[git]
client = '/usr/bin/git' ; Your git executable path
default_branch = 'master' ; Default branch when HEAD is detached
repositories[] = '/home/git/repositories' ; Path to your repositories
                               ; If you wish to add more repositories, just add a new line

; WINDOWS USERS
;client = '"C:\Program Files (x86)\Git\bin\git.exe"' ; Your git executable path
;repositories[] = 'C:\Path\to\Repos\' ; Path to your repositories

; You can hide repositories from GitList, just copy this for each repository you want to hide
; hidden[] = '/home/git/repositories/BetaTest'

[app]
debug = false
cache = true
theme = "default"

; If you need to specify custom filetypes for certain extensions, do this here
[filetypes]
; extension = type
; dist = xml

; If you need to set file types as binary or not, do this here
[binary_filetypes]
; extension = true
; svh = false
; map = true

; set the timezone
[date]
timezone = UTC
format = 'd/m/Y H:i:s'

Here again, everything seem OK too, when I go to http://vm/depot/ I see the list of all the projects in the repository, but when I want to view the content of one, I always get a 404, I assume it's part of the url routing provided by the Silex framework that is used in Gitlist that don't go well with Nginx, but I can't figure how to make it work.

Finally here is my /etc/nginx/sites-enabled/default that I assume is the one in fault

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.html index.htm index.php;

    server_name _;

    location / {
        try_files $uri $uri/ @gitlist =404;
    }

    location ~ \.php$ {
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        # With php5-fpm:
        fastcgi_pass unix:/var/run/php5-fpm.sock;

        include /etc/nginx/fastcgi_params;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        add_header Vary "Accept-Encoding";
        expires max;
        try_files $uri @gitlist;
        tcp_nodelay off;
        tcp_nopush on;
    }

    location @gitlist {
        rewrite ^/.*$ /depot/index.php;
    }
}

I've got one solution from the Gitlist project itself here, but I don't seem to be able to set it right for my case, I always get a 404 when I try to view the project content.

Any suggestions? Thanks in advance

Kane
  • 131
  • 7

2 Answers2

0

Ubuntu 16.04

Structure /var/www/html/gitlist/...

It's working with this config:

server {
    server_name localhost;
    root /var/www/html;
    index index.php;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ \.php$ {
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi.conf;
    }

    location / {
        try_files $uri @gitlist;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        add_header Vary "Accept-Encoding";
        expires max;
        try_files $uri @gitlist;
        tcp_nodelay off;
        tcp_nopush on;
    }

    location @gitlist {
        rewrite ^/gitlist/.*$ /gitlist/index.php;
    }
}
0

I found a turorial that is the exact Nginx configuration, I found on:
https://github.com/patrikx3/gitlist/blob/master/artifacts/gitlist.patrikx3.com.conf

It even enables the git-http-backend.
I use the same config on my server if you check out @
https://gitlist.patrikx3.com

Patrik Laszlo
  • 175
  • 1
  • 10