From 9a936461e6d39f5da088b517731aa5c1d777eeb8 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 10 Sep 2021 22:59:40 +0200 Subject: [PATCH] stream: init --- flake.lock | 8 +-- flake.nix | 8 +++ .../public-access-proxy/default.nix | 6 ++- hosts/containers/stream/default.nix | 54 +++++++++++++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 hosts/containers/stream/default.nix diff --git a/flake.lock b/flake.lock index 72960608..2d1889f1 100644 --- a/flake.lock +++ b/flake.lock @@ -181,11 +181,11 @@ "zentralwerk-network-key": "zentralwerk-network-key" }, "locked": { - "lastModified": 1630966288, - "narHash": "sha256-PbCOvTH+Whi6byuxo1d7A3IxYdXjqDuwjVsE4KNvOSA=", + "lastModified": 1631305227, + "narHash": "sha256-O/R40Yur8Yd6+C/V2FUt5x9T5kRXkfBqU0svvkM0KO4=", "ref": "master", - "rev": "04de05ce751532e6f671be2b36988e54cbed25e4", - "revCount": 1166, + "rev": "c98323c5a904b42e90db385e8e94123d14f96ad4", + "revCount": 1168, "type": "git", "url": "https://gitea.c3d2.de/zentralwerk/network.git" }, diff --git a/flake.nix b/flake.nix index 8990f1c0..01bcbb00 100644 --- a/flake.nix +++ b/flake.nix @@ -319,6 +319,14 @@ system = "x86_64-linux"; }; + stream = nixosSystem' { + modules = [ + ./lib/lxc-container.nix + ./hosts/containers/stream + ]; + system = "x86_64-linux"; + }; + }; nixosModules.c3d2 = import ./lib; diff --git a/hosts/containers/public-access-proxy/default.nix b/hosts/containers/public-access-proxy/default.nix index c9f5637a..233a2545 100644 --- a/hosts/containers/public-access-proxy/default.nix +++ b/hosts/containers/public-access-proxy/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ hostRegistry, config, pkgs, lib, ... }: { imports = [ @@ -35,6 +35,10 @@ hostNames = [ "vps1.nixvita.de" "vps1.codetu.be" "nixvita.de" ]; proxyTo.host = "172.20.73.51"; } + { + hostNames = [ "stream.hq.c3d2.de" ]; + proxyTo.host = hostRegistry.hosts.stream.ip4; + } ]; }; diff --git a/hosts/containers/stream/default.nix b/hosts/containers/stream/default.nix new file mode 100644 index 00000000..e1d0e625 --- /dev/null +++ b/hosts/containers/stream/default.nix @@ -0,0 +1,54 @@ +{ hostRegistry, pkgs, ... }: +let + authFile = pkgs.writeText "htpasswd" "k-ot:sawCOTsl/fIUY"; +in +{ + c3d2.hq.statistics.enable = true; + systemd.network = { + enable = true; + + networks."00-serv" = { + matchConfig.MACAddress = "C6:40:E0:21:9B:A4"; + networkConfig.IPv6AcceptRA = false; + addresses = [ { + addressConfig.Address = "${hostRegistry.hosts.stream.ip4}/26"; + } ]; + routes = [ { + routeConfig = { + Destination = "172.20.0.0/14"; + Gateway = hostRegistry.hosts.serv-gw.ip4; + }; + } ]; + }; + + networks."01-pub" = { + matchConfig.MACAddress = "DE:91:C7:51:D1:C5"; + networkConfig.DHCP = "ipv4"; + }; + }; + networking.firewall.allowedTCPPorts = [ 80 443 ]; + + services.peerflix.enable = true; + + services.nginx = { + enable = true; + recommendedProxySettings = true; + virtualHosts."stream.hq.c3d2.de" = { + default = true; + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:9000"; + extraConfig = '' + auth_basic "Stream"; + auth_basic_user_file ${authFile}; + ''; + }; + }; + }; + + security.acme = { + acceptTerms = true; + email = "mail@c3d2.de"; + }; +}