neko

my cgit setup

hi, this post is mostly for myself so i can set this up quickly if i need to reinstall my vps.

my vps runs ubuntu 20.04 so i’m going to use apt to install cgit:

sudo apt install cgit fcgiwrap

next i’m going to set up the nginx config. apt’s copy of cgit places the .cgi script in /usr/lib/cgit, and the rest of the cgit files in /usr/share/cgit. change the file locations to match your copy.

server {
    listen 80;
    listen [::]:80;
    server_name git.lily.toys;
    root /usr/share/cgit;

    location / {
            try_files $uri @cgit;
    }

    location @cgit {
               fastcgi_pass unix:/var/run/fcgiwrap.socket;
               fastcgi_param SCRIPT_FILENAME /usr/lib/cgit.cgi;
               fastcgi_param SCRIPT_NAME /;
               fastcgi_param PATH_INFO $uri;
               fastcgi_param QUERY_STRING $query_string;
               fastcgi_param REQUEST_METHOD $request_method;
               fastcgi_param CONTENT_TYPE $content_type;
               fastcgi_param CONTENT_LENGTH $content_length;
               fastcgi_param HTTPS $https if_not_empty;
               fastcgi_param SERVER_PORT $server_port;
               fastcgi_param SERVER_NAME $server_name;
    }
}

and last, my /etc/cgitrc:

clone-url=https://$HTTP_HOST/$CGIT_REPO_URL
snapshots=tar.gz zip
remove-suffix=1
enable-git-config=1
scan-path=/home/neko/pub

root-title=nekogit
root-desc="paws on keyboard"