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.
This commit is contained in:
parent
85ff56cdde
commit
027d4188b2
1 changed files with 17 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue