diff options
Diffstat (limited to 'caddy')
| -rw-r--r-- | caddy/Caddyfile | 53 | ||||
| -rw-r--r-- | caddy/caddy.service | 48 | ||||
| -rw-r--r-- | caddy/etc/cgitrc | 49 | ||||
| -rw-r--r-- | caddy/etc/systemd/system/fcgiwrap.service.d/override.conf | 21 | ||||
| -rw-r--r-- | caddy/etc/systemd/system/fcgiwrap.socket.d/override.conf | 4 |
5 files changed, 172 insertions, 3 deletions
diff --git a/caddy/Caddyfile b/caddy/Caddyfile index f4ea329..f8694d2 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -1,14 +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" + } +} + b7j0c.org { + import security root * /usr/local/www - file_server + file_server { + hide .git .env + } } grokloc.com { + import security root * /usr/local/www-grokloc - file_server + file_server { + hide .git .env + } } batonpass.systems { + import security root * /usr/local/www-batonpass - file_server + 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/caddy.service b/caddy/caddy.service new file mode 100644 index 0000000..d41f77e --- /dev/null +++ b/caddy/caddy.service @@ -0,0 +1,48 @@ +# /usr/lib/systemd/system/caddy.service +# caddy.service +# +# view with `systemctl --no-pager cat caddy` +# edit with `systemctl edit caddy` +# +# For using Caddy with a config file. +# +# Make sure the ExecStart and ExecReload commands are correct +# for your installation. +# +# See https://caddyserver.com/docs/install for instructions. +# +# WARNING: This service does not use the --resume flag, so if you +# use the API to make changes, they will be overwritten by the +# Caddyfile next time the service is restarted. If you intend to +# use Caddy's API to configure it, add the --resume flag to the +# `caddy run` command or use the caddy-api.service file instead. + +[Unit] +Description=Caddy +Documentation=https://caddyserver.com/docs/ +After=network.target network-online.target +Requires=network-online.target + +[Service] +Type=notify +User=caddy +Group=caddy +ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile +ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force +TimeoutStopSec=5s +LimitNOFILE=1048576 +LimitNPROC=512 +PrivateTmp=true +ProtectSystem=full +AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target + +# /etc/systemd/system/caddy.service.d/override.conf +[Service] +NoNewPrivileges=true +ProtectHome=true +ProtectKernelTunables=true +ProtectKernelModules=true +CapabilityBoundingSet=CAP_NET_BIND_SERVICE 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 |
