From 9282c414626ba04b1c4d09ae60a3170942c9a48a Mon Sep 17 00:00:00 2001 From: Brad Clawsie Date: Fri, 4 Dec 2026 17:08:22 +0000 Subject: cgit --- caddy/Caddyfile | 73 +++++++++++++++------- caddy/etc/cgitrc | 49 +++++++++++++++ .../system/fcgiwrap.service.d/override.conf | 21 +++++++ .../systemd/system/fcgiwrap.socket.d/override.conf | 4 ++ 4 files changed, 124 insertions(+), 23 deletions(-) create mode 100644 caddy/etc/cgitrc create mode 100644 caddy/etc/systemd/system/fcgiwrap.service.d/override.conf create mode 100644 caddy/etc/systemd/system/fcgiwrap.socket.d/override.conf diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 0283f18..f8694d2 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -1,34 +1,61 @@ (security) { - header { - Content-Security-Policy "default-src 'none'; style-src 'self'; img-src 'self'; font-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'" - X-Content-Type-Options "nosniff" - X-Frame-Options "DENY" - Referrer-Policy "no-referrer" - Permissions-Policy "camera=(), microphone=(), geolocation=()" - Strict-Transport-Security "max-age=31536000" - } + header { + Content-Security-Policy "default-src 'none'; style-src 'self'; img-src 'self'; font-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'" + X-Content-Type-Options "nosniff" + X-Frame-Options "DENY" + Referrer-Policy "no-referrer" + Permissions-Policy "camera=(), microphone=(), geolocation=()" + Strict-Transport-Security "max-age=31536000" + } } b7j0c.org { - import security - root * /usr/local/www - file_server { - hide .git .env - } + import security + root * /usr/local/www + file_server { + hide .git .env + } } grokloc.com { - import security - root * /usr/local/www-grokloc - file_server { - hide .git .env - } + import security + root * /usr/local/www-grokloc + file_server { + hide .git .env + } } batonpass.systems { - import security - root * /usr/local/www-batonpass - file_server { - hide .git .env - } + import security + root * /usr/local/www-batonpass + file_server { + hide .git .env + } +} + +git.b7j0c.org { + encode zstd gzip + + @assets path /cgit.css /cgit.png /cgit.js /favicon.ico /robots.txt + + handle @assets { + root * /usr/share/cgit + file_server + } + + @readonly method GET HEAD + + handle @readonly { + reverse_proxy unix//run/fcgiwrap.socket { + transport fastcgi { + env SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi + env SCRIPT_NAME / + env PATH_INFO {http.request.uri.path} + } + } + } + + handle { + respond "Method Not Allowed" 405 + } } diff --git a/caddy/etc/cgitrc b/caddy/etc/cgitrc new file mode 100644 index 0000000..885328d --- /dev/null +++ b/caddy/etc/cgitrc @@ -0,0 +1,49 @@ +root-title=b7j0c.org +root-desc=Personal Git repositories + +css=/cgit.css +logo=/cgit.png +favicon=/favicon.ico +virtual-root=/ + +cache-size=0 +enable-http-clone=1 +enable-index-links=1 +enable-commit-graph=1 +enable-git-config=0 +enable-filter-overrides=0 + +clone-url=https://git.b7j0c.org/$CGIT_REPO_URL + +repo.url=dotfiles-public +repo.path=/srv/git/dotfiles-public +repo.desc=Public dotfiles + +repo.url=r100 +repo.path=/srv/git/r100 +repo.desc=100 Rust exercises + +repo.url=awsv4-cpp +repo.path=/srv/git/awsv4-cpp +repo.desc=AWS Signature Version 4 implementation in C++ + +repo.url=Hash-Consistent +repo.path=/srv/git/Hash-Consistent +repo.desc=Raku implementation of a consistent hash + +repo.url=Subsets-Common +repo.path=/srv/git/Subsets-Common +repo.desc=Useful Raku subsets + +repo.url=Net-IP-Parse +repo.path=/srv/git/Net-IP-Parse +repo.desc=IPv4 and v6 types for Raku + +repo.url=Webservice-AWS-Auth-V4 +repo.path=/srv/git/Webservice-AWS-Auth-V4 +repo.desc=AWS V4 authentication in Raku + +repo.url=Lang-Go-Mod +repo.path=/srv/git/Lang-Go-Mod +repo.desc=Parse Go .mod files in Perl + diff --git a/caddy/etc/systemd/system/fcgiwrap.service.d/override.conf b/caddy/etc/systemd/system/fcgiwrap.service.d/override.conf new file mode 100644 index 0000000..ab23e98 --- /dev/null +++ b/caddy/etc/systemd/system/fcgiwrap.service.d/override.conf @@ -0,0 +1,21 @@ +[Service] +User=cgit +Group=cgit + +NoNewPrivileges=yes +ProtectSystem=strict +ProtectHome=yes +ProtectKernelTunables=yes +ProtectKernelModules=yes +ProtectKernelLogs=yes +ProtectControlGroups=yes +ProtectClock=yes +PrivateTmp=yes +PrivateDevices=yes +RestrictSUIDSGID=yes +RestrictNamespaces=yes +RestrictAddressFamilies=AF_UNIX +CapabilityBoundingSet= + +ReadOnlyPaths=/srv/git +InaccessiblePaths=/srv/git/notes /srv/git/pass /srv/git/xylabs diff --git a/caddy/etc/systemd/system/fcgiwrap.socket.d/override.conf b/caddy/etc/systemd/system/fcgiwrap.socket.d/override.conf new file mode 100644 index 0000000..7b25f04 --- /dev/null +++ b/caddy/etc/systemd/system/fcgiwrap.socket.d/override.conf @@ -0,0 +1,4 @@ +[Socket] +SocketUser=cgit +SocketGroup=caddy +SocketMode=0660 -- cgit v1.2.3