feat: add web host
This commit is contained in:
parent
df9367d12f
commit
155801244a
3 changed files with 63 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
network = import ../data/network.nix;
|
||||
web = import ../data/web.nix;
|
||||
virtualHostFn = name: service: let
|
||||
domain = if service ? domainOverride
|
||||
then service.domainOverride
|
||||
|
|
@ -54,6 +55,22 @@ let
|
|||
} // serverAlias // sslConfig // externConnections // myExtraConfig;
|
||||
rproxyServices = builtins.mapAttrs (virtualHostFn) network.reverse_proxy;
|
||||
serviceNamesMessage = builtins.toString (builtins.attrNames network.reverse_proxy);
|
||||
webHosts = lib.mapAttrs' (name: description: {
|
||||
name = "${name}.web";
|
||||
value = {
|
||||
serverName = "${name}";
|
||||
listen = [ {addr = "0.0.0.0"; port = 80;} {addr = "0.0.0.0"; port = 443; ssl = true;}];
|
||||
locations = lib.mapAttrs' (endpointName: endpointValue: {
|
||||
name = endpointName;
|
||||
value = {
|
||||
extraConfig = ''
|
||||
default_type ${endpointValue.contentType};
|
||||
return ${toString endpointValue.status} "${endpointValue.content}";
|
||||
'';
|
||||
};
|
||||
}) description;
|
||||
};
|
||||
}) web;
|
||||
fallback = {
|
||||
serverName = "_";
|
||||
listen = [ {addr = "0.0.0.0"; port = 80;}];
|
||||
|
|
@ -77,7 +94,7 @@ in {
|
|||
recommendedOptimisation = true;
|
||||
recommendedGzipSettings = true;
|
||||
|
||||
virtualHosts = rproxyServices // {fallback = fallback;};
|
||||
virtualHosts = rproxyServices // webHosts // {fallback = fallback;};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = network.usedPorts;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue