You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
891 B
31 lines
891 B
{ config, lib, pkgs, vhosts ? { }, domains ? [ ], ... }:
|
|
|
|
let
|
|
served = lib.filterAttrs (k: _: builtins.elem k domains) vhosts;
|
|
enabled = served != { };
|
|
acme = config.infra.acme.enable or false;
|
|
in {
|
|
config = lib.mkIf enabled {
|
|
services.nginx = {
|
|
enable = true;
|
|
virtualHosts = lib.mapAttrs (name: vhost:
|
|
let
|
|
port = vhost.ports.http or null;
|
|
hasProxy = port != null;
|
|
root = vhost.root or null;
|
|
in {
|
|
enableACME = acme;
|
|
forceSSL = acme;
|
|
root = lib.mkIf (root != null) root;
|
|
extraConfig = vhost.extraConfig or "";
|
|
locations."/" = lib.mkIf hasProxy {
|
|
proxyPass = "http://localhost:${toString port}";
|
|
proxyWebsockets = vhost.websockets or false;
|
|
};
|
|
}
|
|
) served;
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
|
};
|
|
}
|
|
|