git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #55024 from telotortium/airsonic-virtualHost

airsonic: Add virtualHost option to set up nginx virtual host

commitadb837eea77470cd6109a3df2692fdd19822c877 authorFranz Pletz <fpletz@fnordicwalking.de> dateTue 12 Feb 2019, 02:09 (8 years ago) parentd47e89b027d418
1 file changed+17
nixos/modules/services/misc/airsonic.nix+17
nixos/modules/services/misc/airsonic.nix+17
@@ -25,6 +25,14 @@ in {
2525 '';
2626 };
2727
28+ virtualHost = mkOption {
29+ type = types.nullOr types.str;
30+ default = null;
31+ description = ''
32+ Name of the nginx virtualhost to use and setup. If null, do not setup any virtualhost.
33+ '';
34+ };
35+
2836 listenAddress = mkOption {
2937 type = types.string;
3038 default = "127.0.0.1";
@@ -116,6 +124,8 @@ in {
116124 -Dserver.port=${toString cfg.port} \
117125 -Dairsonic.contextPath=${cfg.contextPath} \
118126 -Djava.awt.headless=true \
127+ ${optionalString (cfg.virtualHost != null)
128+ "-Dserver.use-forward-headers=true"} \
119129 ${toString cfg.jvmOptions} \
120130 -verbose:gc \
121131 -jar ${pkgs.airsonic}/webapps/airsonic.war
@@ -126,6 +136,13 @@ in {
126136 };
127137 };
128138
139+ services.nginx = mkIf (cfg.virtualHost != null) {
140+ enable = true;
141+ virtualHosts."${cfg.virtualHost}" = {
142+ locations."${cfg.contextPath}".proxyPass = "http://${cfg.listenAddress}:${toString cfg.port}";
143+ };
144+ };
145+
129146 users.users.airsonic = {
130147 description = "Airsonic service user";
131148 name = cfg.user;