Our Goal
The Easy Part
Nginx is fun, and I've used it before with fastcgi. Let's do the easy parts. I've already set gitolite3's UMASK to be a bit less righteous for interoperability with git-daemon+xinited, so we'll move on to the new configuration.
apt-get install fcgiwrap systemctl enable fcgiwrap chmod -R go-rwx /var/lib/gitolite3 chmod -R g+rx /var/lib/gitolite3 adduser www-data gitolite3
server { server_name projects.languidnights.com; listen 443 ssl; list [::]:443 ssl; gzip off; location /cgit/ { root /usr/lib/cgit/; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; fastcgi_pass unix:/run/fcgiwrap.socket fastcgi_param QUERY_STRING $args; fastcgi_param HTTP_HOST $server_name; } location /cgit-css/ { root /usr/share/cgit/; } }
Problem Numero Uno
What do you mean I can't see the stylesheets and images? Oh, you want it to be an alias, not a directory. I got it
/etc/nginx/sites-enabled/projects
--- a 2024-01-21 05:54:37.553311062 +0000 +++ b 2024-01-21 05:54:54.113321210 +0000 @@ -48,6 +48,6 @@ } location /cgit-css/ { - root /usr/share/cgit/; + alias /usr/share/cgit/; } }
Let's configure cgit
It's got a pretty good man page man 5 cgitrc and I did this in
the before times with gitolite2, so let's go.
css=/cgit-css/cgit.css logo=/cgit-css/cgit.png favicon=/cgit-css/favicon.ico root-title=LanguidNights' Git Repositories root-desc=various and sundry enable-index-links=1 enable-git-config=1 remove-suffix=1 project-list=/var/lib/gitolite3/projects.list scan-path=/var/lib/gitolite3/repositories
So Far
It works beautifully. That is, if you happen to be sitting on the server and part of the www-data group.
sudo -u www-data /usr/lib/cgit/cgit.cgi
If, like me, you want your website for your git repos to be viewable on the web, still no joy. It just says 'no repositories found'. I know that's a lie, cgit! Give me your secrets, I'm going mad and it's past midnight! Nothing in my error logs, nothings in my access logs, nothing in my syslog. What is going on?
ls -l /var/lib/gitolite3 cat /var/lib/gitolite3/projects.list systemctl restart fcgiwrap.socket fcgiwrap.service nginx.service
And no joy! You're lucky I'm bald, or I'd have thrown handfuls of my own hair at you!
The Final Pieces
Courtesy of The Arch Linux BBS I finally got the last piece, which I missed in all the relevant documentation. It consisted of two parts
/etc/cgitrc
--- a 2024-01-21 05:42:37.240863180 +0000 +++ b 2024-01-21 05:42:28.244857393 +0000 @@ -6,6 +6,7 @@ logo=/cgit-css/cgit.png favicon=/cgit-css/favicon.ico +virtual-root=/cgit/ root-title=LanguidNight's Git Repositories root-desc=various and sundry enable-index-links=1
/etc/nginx/sites-enabled/projects
--- a 2024-01-21 05:32:23.356460060 +0000 +++ b 2024-01-21 05:32:12.704453273 +0000 @@ -43,6 +43,8 @@ fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; fastcgi_pass unix:/run/fcgiwrap.socket; + fastcgi_split_path_info ^(/cgit/?)(.+)$; + fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param QUERY_STRING $args; fastcgi_param HTTP_HOST $server_name; }
And, we have joy. My life is now better than it was a 3:00pm at least, and I can finally go to bed. Well, just as soon as I write this up for posterity.