Refactored subdomains creation

This commit is contained in:
Julien Malka 2021-12-29 17:40:57 +01:00
parent f6b29709c5
commit be4fce11f4
No known key found for this signature in database
GPG key ID: 3C68E13964FEA07F
11 changed files with 28 additions and 103 deletions

View file

@ -10,6 +10,7 @@ in
{
mkMachine = host: host-config: modules: nixpkgs.lib.nixosSystem {
lib = final;
system = "x86_64-linux";
specialArgs = {
inherit inputs;
@ -36,5 +37,16 @@ in
importConfig = path: (mapAttrs (name: value: import (path + "/${name}/default.nix")) (readDir path));
mkSubdomain = name: port: {
luj.nginx.enable = true;
services.nginx.virtualHosts."${name}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
};
}

View file

@ -32,13 +32,5 @@ with lib;
port = port;
};
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
};
} // mkSubdomain cfg.subdomain port;
}

View file

@ -93,13 +93,5 @@ in
path = [ pkgs.nixUnstable pkgs.git pkgs.openssh ];
};
services.nginx.virtualHosts."${cfg.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
};
} // mkSubdomain cfg.subdomain port;
}

View file

@ -4,10 +4,14 @@ let
cfg = config.luj.filerun;
mysql_root_pw = [ (builtins.readFile /run/secrets/filerun-root-passwd) ];
mysql_pw = [ (builtins.readFile /run/secrets/filerun-passwd) ];
port = 2000;
in
{
options.luj.filerun = {
enable = mkEnableOption "enable filerun service";
subdomain = mkOption {
type = types.str;
};
};
@ -79,26 +83,6 @@ in
extraOptions = [ "--network=filerun-br" ];
};
luj.nginx.enable = true;
services.nginx.recommendedProxySettings = true;
services.nginx.virtualHosts."cloud.julienmalka.me" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:2000";
extraConfig = ''
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
'';
};
};
};
} // mkSubdomain cfg.subdomain port;
}

View file

@ -29,17 +29,8 @@ in
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.hydra.hydraURL = "${cfg.nginx.subdomain}.julienmalka.me";
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);
} // mkSubdomain cfg.nginx.subdomain port )]);

View file

@ -37,17 +37,7 @@ in
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);
(mkIf cfg.nginx.enable (mkSubdomain cfg.nginx.subdomain port) )]);

View file

@ -37,17 +37,7 @@ in
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);
(mkIf cfg.nginx.enable (mkSubdomain cfg.nginx.subdomain port) )]);

View file

@ -22,6 +22,7 @@ in {
enable = true;
recommendedOptimisation = true;
recommendedTlsSettings = true;
recommendedProxySettings = true;
clientMaxBodySize = "128m";
commonHttpConfig = ''

View file

@ -38,17 +38,10 @@ in
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
(mkIf cfg.nginx.enable (mkSubdomain cfg.nginx.subdomain port))
]);
})]);

View file

@ -38,17 +38,7 @@ in
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);
(mkIf cfg.nginx.enable (mkSubdomain cfg.nginx.subdomain port) )]);

View file

@ -52,17 +52,7 @@ in
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);
(mkIf cfg.nginx.enable (mkSubdomain cfg.nginx.subdomain port) )]);