host(koumakan): fix s3 vhost based routing

Changed files
+21 -9
systems
koumakan
certificates
services
storage
+1 -1
systems/koumakan/certificates/default.nix
···
-
{ ... }:
{
imports = [
./global.nix
···
./fediverse.nix
./bsky-pds.nix
./breezewiki.nix
+
./garage-s3.nix
];
}
+10
systems/koumakan/certificates/garage-s3.nix
···
+
{
+
# Certificate for garage domains
+
security.acme.certs."s3.soopy.moe" = {
+
group = "nginx";
+
extraDomainNames = [
+
"*.s3.soopy.moe"
+
"*.s3web.soopy.moe"
+
];
+
};
+
}
+10 -8
systems/koumakan/services/storage/garage.nix
···
# this is needed because garage apparently still doesn't support anon access via path based api, so this is more like a hack than anything atm.
s3_web = {
bind_addr = "[::1]:39939";
-
root_domain = "root.invalid";
+
root_domain = ".s3web.soopy.moe";
};
rpc_bind_addr = "100.100.16.16:39931";
···
Group = config.users.groups.garage.name;
Restart = "on-failure";
StateDirectory = lib.mkForce null; # this somehow breaks mounting dirs into /var/lib; systemd complains about id-mapped mount: device or resource busy
-
# ReadWritePaths = [
-
# "/var/lib/garage"
-
# "/var/lib/garage/data"
-
# "/var/lib/garage/meta"
-
# "/var/lib/garage/snapshots"
-
# ];
};
services.nginx.virtualHosts.".s3.soopy.moe" = _utils.mkSimpleProxy {
port = 39930;
extraConfig = {
+
useACMEHost = "s3.soopy.moe";
extraConfig = ''
client_max_body_size 32G;
proxy_max_temp_file_size 0;
···
};
};
-
services.nginx.virtualHosts."cache.soopy.moe" = _utils.mkSimpleProxy {
+
services.nginx.virtualHosts."*.s3web.soopy.moe" = _utils.mkSimpleProxy {
port = 39939;
+
extraConfig.useACMEHost = "s3.soopy.moe";
};
systemd.services.vmagent.serviceConfig.LoadCredential = [
···
# https://docs.victoriametrics.com/sd_configs/#scrape_configs
# hard coding because we can't use %{ENV_VAR} syntax (yet) when checking.
bearer_token_file = "/run/credentials/vmagent.service/garage_token";
+
};
+
+
##################### NAMED BUCKETS WITH WEB HOSTING ###########################
+
+
services.nginx.virtualHosts."cache.soopy.moe" = _utils.mkSimpleProxy {
+
port = 39939;
};
}