feat: add continuwuity server
This commit is contained in:
parent
2e50350107
commit
4863ab05f5
4 changed files with 73 additions and 15 deletions
|
|
@ -1,20 +1,34 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
network = import ../data/network.nix;
|
||||
rproxyServices = builtins.mapAttrs (name: service: {
|
||||
serverName = "${name}.${network.local_domain}";
|
||||
listen = [ {addr = "0.0.0.0"; port = 80;} ];
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://127.0.0.1:${builtins.toString service.reverse_proxy.port}/";
|
||||
proxyWebsockets = true;
|
||||
virtualHostFn = name: service: let
|
||||
domain = if service.domainOverride == null
|
||||
then "${name}.${network.local_domain}"
|
||||
else service.domainOverride;
|
||||
locationList = if service.reverse_proxy.endpoints == null
|
||||
then ["/"]
|
||||
else service.reverse_proxy.endpoints;
|
||||
locationsData = builtins listToAttrs (map (endpointName: {
|
||||
name = endpointName;
|
||||
value = {
|
||||
proxyPass = "http://127.0.0.1:${builtins.toString service.reverse_proxy.port}/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
}));
|
||||
serverAlias = lib.optionalAttrs (service.reverse_proxy.aliases != null) {
|
||||
serverAliases = map (alias: "${alias}.${domain}") service.reverse_proxy.aliases;
|
||||
};
|
||||
};
|
||||
extraConfig = ''
|
||||
allow ${network.network.subnet};
|
||||
deny all;
|
||||
'';
|
||||
}) network.reverse_proxy;
|
||||
in
|
||||
{
|
||||
serverName = "${domain}";
|
||||
listen = [ {addr = "0.0.0.0"; port = 80;} ];
|
||||
locations = locationsData;
|
||||
extraConfig = ''
|
||||
allow ${network.network.subnet};
|
||||
deny all;
|
||||
'';
|
||||
} // serverAlias;
|
||||
rproxyServices = builtins.mapAttrs (virtualHostFn) network.reverse_proxy;
|
||||
serviceNamesMessage = builtins.toString (builtins.attrNames network.reverse_proxy);
|
||||
fallback = {
|
||||
serverName = "_";
|
||||
|
|
@ -42,6 +56,10 @@ in {
|
|||
virtualHosts = rproxyServices // {fallback = fallback;};
|
||||
};
|
||||
|
||||
# TODO add 443 for https
|
||||
networking.firewall.allowedTCPPorts = [80];
|
||||
networking.firewall.allowedTCPPorts = [80 443];
|
||||
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
defaults.email = "katharina.heidenreich02@gmail.com";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue