forked from hacc/haccfiles
hosts: init cdn-node-1
This commit is contained in:
parent
0878012581
commit
65eda592f3
5 changed files with 138 additions and 3 deletions
|
@ -78,4 +78,7 @@ in {
|
||||||
enable = true;
|
enable = true;
|
||||||
nginx.enable = true;
|
nginx.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
security.acme.email = "info+acme@hacc.space";
|
||||||
|
security.acme.acceptTerms = true;
|
||||||
}
|
}
|
||||||
|
|
26
configuration/hosts/cdn/node-1/configuration.nix
Normal file
26
configuration/hosts/cdn/node-1/configuration.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ # Include the results of the hardware scan.
|
||||||
|
./hardware-config.nix
|
||||||
|
../../../common
|
||||||
|
../../../server/cdn-node.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.loader.grub.enable = true;
|
||||||
|
boot.loader.grub.version = 2;
|
||||||
|
boot.loader.grub.devices = [ "/dev/sda" ];
|
||||||
|
|
||||||
|
networking.interfaces.ens3.useDHCP = true;
|
||||||
|
networking.hostName = "cdn-node-1";
|
||||||
|
|
||||||
|
|
||||||
|
# This value determines the NixOS release from which the default
|
||||||
|
# settings for stateful data, like file locations and database versions
|
||||||
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||||
|
# this value at the release version of the first install of this system.
|
||||||
|
# Before changing this value read the documentation for this option
|
||||||
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||||
|
system.stateVersion = "20.03"; # Did you read the comment?
|
||||||
|
}
|
25
configuration/hosts/cdn/node-1/hardware-config.nix
Normal file
25
configuration/hosts/cdn/node-1/hardware-config.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
|
# and may be overwritten by future invocations. Please make changes
|
||||||
|
# to /etc/nixos/configuration.nix instead.
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ <nixpkgs/nixos/modules/profiles/qemu-guest.nix>
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = [ "ata_piix" "virtio_pci" "xhci_pci" "sd_mod" "sr_mod" ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
fileSystems."/" =
|
||||||
|
{ device = "/dev/disk/by-uuid/52dddb3d-9294-4105-9157-bf003dc7bdf9";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices = [ ];
|
||||||
|
|
||||||
|
nix.maxJobs = lib.mkDefault 1;
|
||||||
|
}
|
||||||
|
|
|
@ -2,13 +2,15 @@ let
|
||||||
hosts = {
|
hosts = {
|
||||||
hainich = {
|
hainich = {
|
||||||
ssh.host = "hainich.hacc.space";
|
ssh.host = "hainich.hacc.space";
|
||||||
channel = "nixos-unstable";
|
|
||||||
groups = [ "server" "hacc" ];
|
groups = [ "server" "hacc" ];
|
||||||
};
|
};
|
||||||
nixda = {
|
nixda = {
|
||||||
ssh.host = "nixda.hacc.space";
|
ssh.host = "nixda.hacc.space";
|
||||||
channel = "nixos-20.09";
|
groups = [ "server" "desktop" "hacc" "live" ];
|
||||||
groups = [ "server" "hacc" "live" ];
|
};
|
||||||
|
"cdn/node-1" = {
|
||||||
|
ssh.host = "cdn-node-1.live.hacc.media";
|
||||||
|
groups = [ "server" "hacc" "live" "livecdn" "livecdn-node" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
pkgs = import <nixpkgs> {};
|
pkgs = import <nixpkgs> {};
|
||||||
|
|
79
configuration/server/cdn-node.nix
Normal file
79
configuration/server/cdn-node.nix
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
{config, lib, pkgs, ...}:
|
||||||
|
|
||||||
|
{
|
||||||
|
networking.firewall.allowedTCPPorts = [
|
||||||
|
80 # HTTP
|
||||||
|
443 # HTTPs
|
||||||
|
];
|
||||||
|
|
||||||
|
services.netdata = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable nginx service
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
# Use recommended settings
|
||||||
|
# Don't use recommended Proxy settings because it does funky things with the setup
|
||||||
|
recommendedGzipSettings = true;
|
||||||
|
recommendedOptimisation = true;
|
||||||
|
recommendedTlsSettings = true;
|
||||||
|
virtualHosts."${config.networking.hostName}.live.hacc.media" = {
|
||||||
|
forceSSL = true;
|
||||||
|
enableACME = true;
|
||||||
|
# basicAuth = basicAuthLogin;
|
||||||
|
locations = {
|
||||||
|
"~* \\.(m3u8)$" = {
|
||||||
|
proxyPass = "https://cdn-master.live.hacc.media$request_uri";
|
||||||
|
extraConfig = ''
|
||||||
|
#proxy_cache = off;
|
||||||
|
expires 3s;
|
||||||
|
auth_basic off;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
"/hls" = {
|
||||||
|
proxyPass = "https://cdn-master.live.hacc.media$request_uri";
|
||||||
|
extraConfig = ''
|
||||||
|
types {
|
||||||
|
application/vnd.apple.mpegurl m3u8;
|
||||||
|
video/mp2t ts;
|
||||||
|
}
|
||||||
|
proxy_cache hls;
|
||||||
|
proxy_ignore_headers Cache-Control;
|
||||||
|
proxy_cache_valid any 30m;
|
||||||
|
auth_basic off;
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
"/stats" = {
|
||||||
|
return = "301 /stats/";
|
||||||
|
};
|
||||||
|
"~ /stats/(?<ndpath>.*)" = {
|
||||||
|
proxyPass = "http://127.0.0.1:19999/$ndpath$is_args$args";
|
||||||
|
extraConfig = ''
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Server $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_pass_request_headers on;
|
||||||
|
proxy_set_header Connection "keep-alive";
|
||||||
|
proxy_store off;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_types *;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
appendHttpConfig = ''
|
||||||
|
proxy_cache_path /tmp keys_zone=hls:10m max_size=10g inactive=60m use_temp_path=on;
|
||||||
|
resolver 1.1.1.1;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue