Shami's Blog

Sysadmin, Because Even Developers Need Heroes

Allowing Read-Only Access To A Git Repository Via HTTP

2017-04-02 by Mohammad H. Al-Shami

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.

server {
    listen                80;
    server_name ;
    root                  /usr/local/www/cgit;
    try_files             $uri @cgit;

    location @cgit {
      include             fastcgi_params;
      fastcgi_param       SCRIPT_FILENAME $document_root/cgit.cgi;
      fastcgi_param       PATH_INFO       $uri;
      fastcgi_param       QUERY_STRING    $args;
      fastcgi_param       HTTP_HOST       $server_name;
      fastcgi_pass        unix:/var/run/fcgiwrap/fcgiwrap.sock;
# cgit config


# if you do not want that webcrawler (like google) index your site
robots=noindex, nofollow

# if cgit messes up links, use a virtual-root. For example has this value:

# Use the following to scan for repositories in a folder
# scan-path=/usr/local/www/

repo.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.