feat(nixosModules/server): add nginx

This commit is contained in:
Mohammad Rafiq 2025-06-04 20:31:37 +08:00
parent d478e9009f
commit 5ba9667f4e
No known key found for this signature in database
4 changed files with 28 additions and 34 deletions

View file

@ -1,24 +0,0 @@
{ config, lib, ... }:
let
cfg = config.server.reverse-proxy;
in
{
options.server.reverse-proxy = {
enable = lib.mkEnableOption "";
type = lib.pantheon.mkStrOption;
proxies = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
default = [ ];
};
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
(lib.mkIf (cfg.type == "nginx") {
services.nginx = {
enable = true;
};
})
]
);
}

View file

@ -0,0 +1,27 @@
{ config, lib, ... }:
let
cfg = config.server.web-servers;
in
{
options.server.web-servers = {
nginx = {
enable = lib.mkEnableOption "the Nginx server";
};
};
config = lib.mkMerge [
(lib.mkIf cfg.nginx.enable {
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx = {
enable = true;
virtualHosts.${config.system.hostname} = {
locations."/" = {
return = "200 '<html><body>It works!</body></html'";
extraConfig = ''
default_type text/html;
'';
};
};
};
})
];
}

View file

@ -25,6 +25,7 @@
databases.mongodb.enable = true; databases.mongodb.enable = true;
databases.mysql.enable = true; databases.mysql.enable = true;
librechat.enable = true; librechat.enable = true;
web-servers.nginx.enable = true;
}; };
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

View file

@ -42,16 +42,6 @@
server = { server = {
mountHelios = true; mountHelios = true;
reverse-proxy = {
enable = true;
type = "nginx";
proxies = [
{
source = "chat.bwfiq.com";
target = "";
}
];
};
}; };
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";