feat(access): mpd

This commit is contained in:
arcnmx 2024-09-05 00:59:42 -07:00
parent 2340ca381d
commit d699eea7ff
3 changed files with 85 additions and 0 deletions

73
nixos/access/mpd.nix Normal file
View file

@ -0,0 +1,73 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkDefault;
name.shortServer = mkDefault "radio";
upstreamName = "radio'access";
upstreamHigh = "${upstreamName}'high";
upstreamLow = "${upstreamName}'low";
in {
config.services.nginx = {
upstreams' = {
${upstreamHigh} = {
servers.service = {
#accessService.system = "shanghai";
addr = "shanghai.local.cutie.moe";
port = 32101;
};
};
${upstreamLow} = {
servers.service = {
#accessService.system = "shanghai";
addr = "shanghai.local.cutie.moe";
port = 32102;
};
};
};
virtualHosts = let
copyFromVhost = mkDefault "mpd";
extraConfig = ''
proxy_buffering off;
'';
locations = {
"/low" = {
inherit extraConfig;
proxy = {
enable = true;
upstream = mkDefault upstreamLow;
};
};
"/high" = {
inherit extraConfig;
proxy = {
enable = true;
upstream = mkDefault upstreamHigh;
};
};
"/" = {
extraConfig = ''
rewrite ^.*$ /high last;
return 404;
'';
};
};
in {
mpd = {
inherit name locations;
proxy.upstream = mkDefault upstreamName;
};
mpd'local = {
inherit name locations;
ssl.cert = {
inherit copyFromVhost;
};
proxy = {
inherit copyFromVhost;
};
local.enable = mkDefault true;
};
};
};
}