Permalink
Browse files

Merge pull request #55024 from telotortium/airsonic-virtualHost

airsonic: Add virtualHost option to set up nginx virtual host
  • Loading branch information...
fpletz committed Feb 12, 2019
2 parents d47e89b + 027d418 commit adb837eea77470cd6109a3df2692fdd19822c877
Showing with 17 additions and 0 deletions.
  1. +17 −0 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;

0 comments on commit adb837e

Please sign in to comment.