38 lines
1.0 KiB
Nix
38 lines
1.0 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
proxy,
|
|
setup,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.my.servers.audiobookshelf;
|
|
in
|
|
{
|
|
options.my.servers.audiobookshelf = setup.mkOptions "audiobookshelf" "audiobooks" 5687;
|
|
config = {
|
|
networking.firewall.allowedTCPPorts = lib.mkIf (!cfg.isLocal) [ cfg.port ];
|
|
services = {
|
|
audiobookshelf = lib.mkIf cfg.enable {
|
|
inherit (cfg) port;
|
|
enable = true;
|
|
group = "piracy";
|
|
};
|
|
nginx.virtualHosts."${cfg.host}" = lib.mkIf cfg.enableProxy (proxy {
|
|
"/" = {
|
|
proxyPass = cfg.local;
|
|
extraConfig = ''
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_http_version 1.1;
|
|
proxy_redirect http:// https://;
|
|
'';
|
|
};
|
|
});
|
|
};
|
|
};
|
|
}
|