diff options
Diffstat (limited to 'nixos/modules/services/misc/airsonic.nix')
-rw-r--r-- | nixos/modules/services/misc/airsonic.nix | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/airsonic.nix b/nixos/modules/services/misc/airsonic.nix index 01d7b3cf6b9d..8b2ec82c7705 100644 --- a/nixos/modules/services/misc/airsonic.nix +++ b/nixos/modules/services/misc/airsonic.nix @@ -25,6 +25,14 @@ in { ''; }; + virtualHost = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Name of the nginx virtualhost to use and setup. If null, do not setup any virtualhost. + ''; + }; + listenAddress = mkOption { type = types.string; default = "127.0.0.1"; @@ -116,6 +124,8 @@ in { -Dserver.port=${toString cfg.port} \ -Dairsonic.contextPath=${cfg.contextPath} \ -Djava.awt.headless=true \ + ${optionalString (cfg.virtualHost != null) + "-Dserver.use-forward-headers=true"} \ ${toString cfg.jvmOptions} \ -verbose:gc \ -jar ${pkgs.airsonic}/webapps/airsonic.war @@ -126,6 +136,13 @@ in { }; }; + services.nginx = mkIf (cfg.virtualHost != null) { + enable = true; + virtualHosts."${cfg.virtualHost}" = { + locations."${cfg.contextPath}".proxyPass = "http://${cfg.listenAddress}:${toString cfg.port}"; + }; + }; + users.users.airsonic = { description = "Airsonic service user"; name = cfg.user; |