Shami's Blog

DevOps because uptime is not optional

Allowing Read-Only Access To A Git Repository Via HTTP

Today I thought about a way to easily distribute an Ansible playbook. I thought about having a tgz file somewhere but I wanted read only access through HTTP in case I wanted to update clients that have already downloaded the content.

The easiest solution I have found was using cgit . Simply run it with nginx and fcgiwrap .

 1server {
 2    listen                80;
 3    server_name           git.example.com;
 4    root                  /usr/local/www/cgit;
 5    try_files             $uri @cgit;
 6
 7    location @cgit {
 8      include             fastcgi_params;
 9      fastcgi_param       SCRIPT_FILENAME $document_root/cgit.cgi;
10      fastcgi_param       PATH_INFO       $uri;
11      fastcgi_param       QUERY_STRING    $args;
12      fastcgi_param       HTTP_HOST       $server_name;
13      fastcgi_pass        unix:/var/run/fcgiwrap/fcgiwrap.sock;
14    }
15  }
1#/etc/rc.conf
2fcgiwrap_socket_owner=www
3fcgiwrap_user="www"
4fcgiwrap_enable="YES"
 1#/usr/local/etc/cgitrc
 2#
 3# cgit config
 4#
 5
 6css=/cgit.css
 7logo=/cgit.png
 8
 9# if you do not want that webcrawler (like google) index your site
10robots=noindex, nofollow
11
12# if cgit messes up links, use a virtual-root. For example has cgit.example.org/ this value:
13virtual-root=/
14
15# Use the following to scan for repositories in a folder
16# scan-path=/usr/local/www/
17
18repo.url=MyRepo
19repo.path=/usr/local/www/git
20repo.desc=This is my git repository

About Me

Dev gone Ops gone DevOps. Any views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.

Categories