aboutsummaryrefslogtreecommitdiff
path: root/content/docs/adyxax.org/git/cgit.md
blob: 75ffa5d82127965a89bdce917ac7d16b230be48e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: "cgit and nginx"
description: Installation notes of cgit
---

## Introduction

This article details how I installed and configured cgit on FreeBSD to serve as the web frontend of my gitolite repositories.

## Installation

cgit can be bootstrapped with the following :
```yaml
pkg install cgit fcgiwrap
```

## Configuration

Here is my `/usr/local/etc/cgitrc-adyxax` file:
```cfg
about-filter=/usr/local/lib/cgit/filters/about-formatting.sh
clone-url=https://$HTTP_HOST/$CGIT_REPO_URL
enable-commit-graph=1
enable-follow-links=1
enable-git-config=1
enable-log-filecount=1
enable-log-linecount=1
enable-subject-links=1
mimetype.gif=image/gif
mimetype.html=text/html
mimetype.jpg=image/jpeg
mimetype.jpeg=image/jpeg
mimetype.pdf=application/pdf
mimetype.png=image/png
mimetype.svg=image/svg+xml
noplainemail=1
readme=:README.md
remove-suffix=1
snapshots=tar.gz tar.bz2 zip
root-desc=All public git repositories by Adyxax
#root-readme=/var/www/htdocs/about.html
root-title=Adyxax's git repositories
virtual-root=/
scan-path=/home/git/repositories
```

## fcgiwrap

fcgiwrap is a necessary interface for nginx to call cgit. It is entirely configured from `/etc/rc.conf`, you just need to add:
```cfg
fcgiwrap_enable="YES"
fcgiwrap_profiles="git"
fcgiwrap_git_socket="unix:/var/run/fcgiwrap/git.socket"
fcgiwrap_git_user="git"
fcgiwrap_git_group="git"
fcgiwrap_git_socket_owner="www"
fcgiwrap_git_socket_group="www"
```

This ensures the cgit processes run as the `git` user, while nginx running as the `www` user can connect to it.

## nginx

I presume nginx is already setup, here is the snippet of configuration needed to serve cgit with fcgiwrap:
```cfg
server {
        listen     80;
        listen     [::]:80;
        server_name  git.adyxax.org;
        location / {
                return 308 https://$server_name$request_uri;
        }
}
server {
        listen     443 ssl;
        listen     [::]:443 ssl;
        server_name  git.adyxax.org;
        location /adyxax {
                try_files $uri @cgit-adyxax;
        }
        location @cgit-adyxax {
                include fastcgi_params;
                fastcgi_param CGIT_CONFIG /usr/local/etc/cgitrc-adyxax;
                fastcgi_param SCRIPT_FILENAME /usr/local/www/cgit/cgit.cgi;
                fastcgi_param PATH_INFO $uri;
                fastcgi_param QUERY_STRING $args;
                fastcgi_param HTTP_HOST $server_name;
                fastcgi_pass unix:/var/run/fcgiwrap/git.socket;
        }

        ssl_certificate /usr/local/etc/adyxax.org.fullchain;
        ssl_certificate_key /usr/local/etc/adyxax.org.key;
}
```