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
|
@ -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 {
|
listenAddress = mkOption {
|
||||||
type = types.string;
|
type = types.string;
|
||||||
default = "127.0.0.1";
|
default = "127.0.0.1";
|
||||||
|
@ -116,6 +124,8 @@ in {
|
||||||
-Dserver.port=${toString cfg.port} \
|
-Dserver.port=${toString cfg.port} \
|
||||||
-Dairsonic.contextPath=${cfg.contextPath} \
|
-Dairsonic.contextPath=${cfg.contextPath} \
|
||||||
-Djava.awt.headless=true \
|
-Djava.awt.headless=true \
|
||||||
|
${optionalString (cfg.virtualHost != null)
|
||||||
|
"-Dserver.use-forward-headers=true"} \
|
||||||
${toString cfg.jvmOptions} \
|
${toString cfg.jvmOptions} \
|
||||||
-verbose:gc \
|
-verbose:gc \
|
||||||
-jar ${pkgs.airsonic}/webapps/airsonic.war
|
-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 = {
|
users.users.airsonic = {
|
||||||
description = "Airsonic service user";
|
description = "Airsonic service user";
|
||||||
name = cfg.user;
|
name = cfg.user;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user