diff options
author | Robert Irelan <rirelan@gmail.com> | 2019-01-31 17:09:06 -0800 |
---|---|---|
committer | Robert Irelan <rirelan@gmail.com> | 2019-02-05 00:15:54 -0800 |
commit | 027d4188b27fc7139edfa4b2c463497c731f66a2 (patch) | |
tree | 81d451af06b363c0399d24c817779a0cf416c606 /nixos/modules | |
parent | 85ff56cdde104a09b7de6e92fa0d50e836b64688 (diff) | |
download | nixpkgs-027d4188b27fc7139edfa4b2c463497c731f66a2.tar nixpkgs-027d4188b27fc7139edfa4b2c463497c731f66a2.tar.gz nixpkgs-027d4188b27fc7139edfa4b2c463497c731f66a2.tar.bz2 nixpkgs-027d4188b27fc7139edfa4b2c463497c731f66a2.tar.lz nixpkgs-027d4188b27fc7139edfa4b2c463497c731f66a2.tar.xz nixpkgs-027d4188b27fc7139edfa4b2c463497c731f66a2.tar.zst nixpkgs-027d4188b27fc7139edfa4b2c463497c731f66a2.zip |
airsonic: Add virtualHost option to set up nginx virtual host
Modeled after nixos/modules/services/web-apps/tt-rss.nix. The setup is slightly non-intuitive, so I think it's worth adding upstream.
Diffstat (limited to 'nixos/modules')
-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 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; |