summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2019-02-12 02:09:25 +0000
committerGitHub <noreply@github.com>2019-02-12 02:09:25 +0000
commitadb837eea77470cd6109a3df2692fdd19822c877 (patch)
treef1f602c2ce1788516d0cbd05cdf43906b88e7c3e /nixos
parentd47e89bc8ba193b26b4a92b583eeae18a90c6567 (diff)
parent027d4188b27fc7139edfa4b2c463497c731f66a2 (diff)
downloadnixpkgs-adb837eea77470cd6109a3df2692fdd19822c877.tar
nixpkgs-adb837eea77470cd6109a3df2692fdd19822c877.tar.gz
nixpkgs-adb837eea77470cd6109a3df2692fdd19822c877.tar.bz2
nixpkgs-adb837eea77470cd6109a3df2692fdd19822c877.tar.lz
nixpkgs-adb837eea77470cd6109a3df2692fdd19822c877.tar.xz
nixpkgs-adb837eea77470cd6109a3df2692fdd19822c877.tar.zst
nixpkgs-adb837eea77470cd6109a3df2692fdd19822c877.zip
Merge pull request #55024 from telotortium/airsonic-virtualHost
airsonic: Add virtualHost option to set up nginx virtual host
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/airsonic.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/airsonic.nix b/nixos/modules/services/misc/airsonic.nix
index 01d7b3cf6b9..8b2ec82c770 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;