refactor(nginx): add proxies option
This commit is contained in:
parent
a157a41cca
commit
f1324f15ed
2 changed files with 44 additions and 25 deletions
|
@ -6,6 +6,29 @@ in
|
||||||
options.server.web-servers = {
|
options.server.web-servers = {
|
||||||
nginx = {
|
nginx = {
|
||||||
enable = lib.mkEnableOption "the Nginx server";
|
enable = lib.mkEnableOption "the Nginx server";
|
||||||
|
proxies = lib.mkOption {
|
||||||
|
type =
|
||||||
|
with lib.types;
|
||||||
|
listOf (submodule {
|
||||||
|
options = {
|
||||||
|
source = lib.pantheon.mkStrOption;
|
||||||
|
target = lib.pantheon.mkStrOption;
|
||||||
|
extraConfig = lib.mkOption {
|
||||||
|
type = attrs;
|
||||||
|
default = { };
|
||||||
|
description = "Will be added to locations.\"/\"";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default = [ ];
|
||||||
|
example = [
|
||||||
|
{
|
||||||
|
source = "chat.bwfiq.com";
|
||||||
|
target = "http://helios:3080";
|
||||||
|
extraConfig = { };
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = lib.mkMerge [
|
config = lib.mkMerge [
|
||||||
|
@ -22,32 +45,18 @@ in
|
||||||
];
|
];
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
virtualHosts = {
|
virtualHosts = builtins.listToAttrs (
|
||||||
"chat.bwfiq.com" = {
|
builtins.map (proxy: {
|
||||||
forceSSL = true;
|
name = proxy.source;
|
||||||
enableACME = true;
|
value = {
|
||||||
locations."/" = {
|
forceSSL = true;
|
||||||
proxyPass = "http://helios:3080";
|
enableACME = true;
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = proxy.target;
|
||||||
|
} // proxy.extraConfig;
|
||||||
};
|
};
|
||||||
};
|
}) cfg.nginx.proxies
|
||||||
"il.bwfiq.com" = {
|
);
|
||||||
forceSSL = true;
|
|
||||||
enableACME = true;
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://helios:2283";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
${config.system.hostname} = {
|
|
||||||
forceSSL = true;
|
|
||||||
enableACME = true;
|
|
||||||
locations."/" = {
|
|
||||||
return = "200 '<html><body>It works!</body></html'";
|
|
||||||
extraConfig = ''
|
|
||||||
default_type text/html;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
@ -26,6 +26,16 @@
|
||||||
databases.mysql.enable = true;
|
databases.mysql.enable = true;
|
||||||
web-apps.librechat.enable = true;
|
web-apps.librechat.enable = true;
|
||||||
web-servers.nginx.enable = true;
|
web-servers.nginx.enable = true;
|
||||||
|
web-servers.nginx.proxies = [
|
||||||
|
{
|
||||||
|
source = "chat.bwfiq.com";
|
||||||
|
target = "http://helios:3080";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source = "il.bwfiq.com";
|
||||||
|
target = "http://helios:2283";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue