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 = {
|
||||
nginx = {
|
||||
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 [
|
||||
|
@ -22,32 +45,18 @@ in
|
|||
];
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"chat.bwfiq.com" = {
|
||||
virtualHosts = builtins.listToAttrs (
|
||||
builtins.map (proxy: {
|
||||
name = proxy.source;
|
||||
value = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://helios:3080";
|
||||
};
|
||||
};
|
||||
"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;
|
||||
'';
|
||||
};
|
||||
};
|
||||
proxyPass = proxy.target;
|
||||
} // proxy.extraConfig;
|
||||
};
|
||||
}) cfg.nginx.proxies
|
||||
);
|
||||
};
|
||||
})
|
||||
];
|
||||
|
|
|
@ -26,6 +26,16 @@
|
|||
databases.mysql.enable = true;
|
||||
web-apps.librechat.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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue