feat(y2q): add caddy

- Add a runit service for Caddy with a Caddyfile
- Update cloudflared runit service:
  - Add support for multiple subdomains using dynamic YAML generation
  - Each subdomain routes to Caddy running on localhost (port 8080)
This commit is contained in:
toast 2025-12-08 17:14:57 +09:00
parent 431847b59f
commit cee1c9bc5d
2 changed files with 41 additions and 5 deletions

View file

@ -1,7 +1,10 @@
{ pkgs, config, rootPath, ... }:
{ pkgs, config, rootPath, lib, ... }:
let
tunnel = "cb0d9c2c-48f9-4bca-9e81-ef92423c5afa";
subdomains = [
"gist.toast.name"
];
in
{
home.file.".cloudflared/${tunnel}.json".source = rootPath + /secrets/gitcrypt/cloudflared/${tunnel}.json;
@ -11,10 +14,11 @@ in
credentials-file: ${config.home.homeDirectory}/.cloudflared/${tunnel}.json
ingress:
- hostname: gist.toast.name
service: http://${config.runit.services.opengist.environment.OG_HTTP_HOST}:${config.runit.services.opengist.environment.OG_HTTP_PORT}
- service: http_status:404
${lib.concatMapStringsSep "\n" (host: ''
${" "}- hostname: ${host}
${" "} service: http://localhost:80
'') subdomains}
${" "}- service: http_status:404
'';
runit.services.cloudflared = {