Merge remote-tracking branch 'gum/master'

This commit is contained in:
lassulus 2016-12-25 12:13:49 +01:00
commit 9224478adf
23 changed files with 423 additions and 476 deletions

View File

@ -22,6 +22,16 @@ let
servers = mkOption { servers = mkOption {
type = with types; attrsOf optionSet; type = with types; attrsOf optionSet;
example = ''
{
"paste.r" = {
defaultPermissions = "read,delete,create";
};
"paste.krebsco.de" = {
defaultPermissions = "read";
};
}
'';
options = singleton { options = singleton {
nginx = mkOption { nginx = mkOption {
# TODO use the correct type # TODO use the correct type
@ -30,7 +40,6 @@ let
additional nginx configuration. see krebs.nginx for all options additional nginx configuration. see krebs.nginx for all options
''; '';
}; };
secretKey = mkOption { secretKey = mkOption {
type = types.str; type = types.str;
description = '' description = ''
@ -39,6 +48,7 @@ let
default = ""; default = "";
}; };
# we create a wsgi socket in $workDir/gunicorn-${name}.wsgi # we create a wsgi socket in $workDir/gunicorn-${name}.wsgi
workDir = mkOption { workDir = mkOption {
type = types.str; type = types.str;
@ -143,25 +153,25 @@ let
}; };
nginx-imp = { nginx-imp = {
assertions = [{ assertion = config.krebs.nginx.enable; assertions = [{ assertion = config.services.nginx.enable;
message = "krebs.nginx.enable must be true"; }]; message = "services.nginx.enable must be true"; }];
krebs.nginx.servers = mapAttrs' (name: server: services.nginx.virtualHosts = mapAttrs ( name: server:
nameValuePair("bepasty-server-${name}") (mkMerge [
(mkMerge [ server.nginx { server.nginx
extraConfig = '' {
client_max_body_size 32M; extraConfig = ''
''; client_max_body_size 32M;
locations = [ '';
(nameValuePair "/" '' locations = {
proxy_set_header Host $http_host; "/".extraConfig = "proxy_set_header Host $http_host;";
proxy_pass http://unix:${server.workDir}/gunicorn-${name}.sock; "/".proxyPass = "http://unix:${server.workDir}/gunicorn-${name}.sock";
'') "/static/".extraConfig = ''
(nameValuePair "/static/" '' alias ${bepasty}/lib/${python.libPrefix}/site-packages/bepasty/static/;
alias ${bepasty}/lib/${python.libPrefix}/site-packages/bepasty/static/; '';
'') };
]; }])
}])) cfg.servers ; ) cfg.servers ;
}; };
in in
out out

View File

@ -35,35 +35,28 @@ let
nginx = { nginx = {
enable = mkEnableOption "enable tinc_graphs to be served with nginx"; enable = mkEnableOption "enable tinc_graphs to be served with nginx";
anonymous = { anonymous = mkOption {
server-names = mkOption { type = types.attrsOf types.unspecified;
type = with types; listOf str; description = ''
description = "hostnames which serve anonymous graphs"; nginx virtualHost options to be merged into the anonymous graphs
default = [ "graphs.${config.krebs.build.host.name}" ]; vhost entry.
}; '';
};
listen = mkOption { anonymous-domain = mkOption {
# use the type of the nginx listen option type = types.str;
type = with types; listOf str; description = ''
description = "listen address for anonymous graphs"; external domainname to be used for anonymous graphs
default = [ "80" ]; it will be used if you want to enable ACME
}; '';
default = "graphs.krebsco.de";
}; };
complete = { complete = mkOption {
server-names = mkOption { type = types.attrsOf types.unspecified;
type = with types; listOf str; description = ''
description = "hostname which serves complete graphs"; nginx virtualHost options to be merged into the complete graphs
default = [ "graphs.${config.krebs.build.host.name}" ]; vhost entry.
}; '';
listen = mkOption {
type = with types; listOf str;
description = "listen address for complete graphs";
default = [ "127.0.0.1:80" ];
};
}; };
}; };
@ -134,24 +127,20 @@ let
uid = genid "tinc_graphs"; uid = genid "tinc_graphs";
home = "/var/spool/tinc_graphs"; home = "/var/spool/tinc_graphs";
}; };
krebs.nginx = mkIf cfg.nginx.enable { services.nginx = mkIf cfg.nginx.enable {
enable = mkDefault true; enable = mkDefault true;
servers = { virtualHosts = {
tinc_graphs_complete = mkMerge [ cfg.nginx.complete { tinc_graphs_complete = mkMerge [ cfg.nginx.complete {
locations = [ locations = {
(nameValuePair "/" '' "/".extraConfig = "autoindex on;";
autoindex on; "/".root = internal_dir;
root ${internal_dir}; };
'') }];
]; "${cfg.nginx.anonymous-domain}" = mkMerge [ cfg.nginx.anonymous {
}] ; locations = {
tinc_graphs_anonymous = mkMerge [ cfg.nginx.anonymous { "/".extraConfig = "autoindex on;";
locations = [ "/".root = external_dir;
(nameValuePair "/" '' };
autoindex on;
root ${external_dir};
'')
];
}]; }];
}; };
}; };

View File

@ -1,27 +1,111 @@
{ config, pkgs, ... }: { config, pkgs, lib, ... }:
{ let
toMapper = id: "/media/crypt${builtins.toString id}";
byid = dev: "/dev/disk/by-id/" + dev;
keyFile = byid "usb-Intuix_DiskOnKey_09A07360336198F8-0:0";
rootDisk = byid "ata-INTEL_SSDSA2M080G2GC_CVPO003402PB080BGN";
rootPartition = rootDisk + "-part3";
dataDisks = let
idpart = dev: byid dev + "-part1";
in [
{ name = "crypt0"; device = idpart "scsi-1ATA_HUA722020ALA330_B9GDLJEF";}
{ name = "crypt1"; device = idpart "scsi-1ATA_HUA722020ALA330_B9GGWG8F";}
{ name = "crypt2"; device = idpart "scsi-1ATA_HUA722020ALA330_B9GH5NAF";}
{ name = "crypt3"; device = idpart "scsi-1ATA_HUA722020ALA330_B9GJWGDF";}
{ name = "crypt4"; device = idpart "scsi-1ATA_HUA722020ALA330_B9GKKXHF";}
{ name = "crypt5"; device = idpart "scsi-1ATA_HUA722020ALA330_B9GKKXVF";}
{ name = "crypt6"; device = idpart "scsi-1ATA_HUA722020ALA330_YAJJ8WRV";}
{ name = "crypt7"; device = idpart "scsi-1ATA_HUA722020ALA330_YBKTUS4F";} # parity
];
disks = [ { name = "luksroot"; device = rootPartition; } ] ++ dataDisks;
in {
imports = [ imports = [
../. ../.
# configure your hw:
# ../2configs/hw/CAC.nix
# ../2configs/fs/CAC-CentOS-7-64bit.nix
../2configs/save-diskspace.nix
../2configs/tinc/retiolum.nix ../2configs/tinc/retiolum.nix
../2configs/disable_v6.nix
../2configs/torrent.nix
../2configs/fs/sda-crypto-root.nix
../2configs/elchos/irc-token.nix
../2configs/elchos/log.nix
../2configs/elchos/search.nix
../2configs/elchos/stats.nix
]; ];
krebs = { makefu.server.primary-itf = "enp8s0f0";
enable = true; krebs = {
build.host = config.krebs.hosts.fileleech; enable = true;
}; build.host = config.krebs.hosts.fileleech;
};
# git clone https://github.com/makefu/docker-pyload
# docker build .
# docker run -d -v /var/lib/pyload:/opt/pyload/pyload-config -v /media/crypt0/pyload:/opt/pyload/Downloads --name pyload --restart=always -p 8112:8000 -P docker-pyload
boot.loader.grub.enable = true; virtualisation.docker.enable = true; # for pyload
boot.loader.grub.version = 2; networking.firewall.allowedTCPPorts = [
boot.loader.grub.device = "/dev/disk/by-id/ata-INTEL_SSDSA2M080G2GC_CVPO003402PB080BGN"; 51412 # torrent
fileSystems."/" = { 8112 # rutorrent-web
device = "/dev/disk/by-id/ata-INTEL_SSDSA2M080G2GC_CVPO003402PB080BGN"; 8113 # pyload
}; 8080 # sabnzbd
9090 # sabnzbd-ssl
655 # tinc
];
networking.firewall.allowedUDPPorts = [
655 # tinc
51412 # torrent
];
boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "ahci" "aacraid" "usb_storage" "usbhid" ]; services.sabnzbd.enable = true;
boot.kernelModules = [ "kvm-intel" ]; systemd.services.sabnzbd.environment.SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
boot.extraModulePackages = [ ];
boot.initrd.luks = {
devices = let
usbkey = name: device: {
inherit name device keyFile;
keyFileSize = 4096;
allowDiscards = true;
};
in builtins.map (x: usbkey x.name x.device) disks;
};
environment.systemPackages = with pkgs;[ mergerfs ];
fileSystems = let
cryptMount = name:
{ "/media/${name}" = { device = "/dev/mapper/${name}"; fsType = "xfs"; };};
in cryptMount "crypt0"
// cryptMount "crypt1"
// cryptMount "crypt2"
// cryptMount "crypt3"
// cryptMount "crypt4"
// cryptMount "crypt5"
// cryptMount "crypt6"
// cryptMount "crypt7"
# this entry sometimes creates issues
// { "/media/cryptX" = {
device = (lib.concatMapStringsSep ":" (d: (toMapper d)) [ 0 1 2 3 4 5 6 ]);
fsType = "mergerfs";
noCheck = true;
options = [ "defaults" "nofail" "allow_other" "nonempty" ]; };
}
;
makefu.snapraid = {
enable = true;
disks = map toMapper [ 0 1 2 3 4 5 6 ];
parity = toMapper 7;
};
boot.loader.grub.device = rootDisk;
boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "ahci" "aacraid" "usb_storage" "usbhid" ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
# http://blog.hackathon.de/using-unsupported-sfp-modules-with-linux.html
boot.extraModprobeConfig = ''
options ixgbe allow_unsupported_sfp=1
'';
} }

View File

@ -15,6 +15,7 @@ in {
../2configs/git/cgit-retiolum.nix ../2configs/git/cgit-retiolum.nix
# ../2configs/mattermost-docker.nix # ../2configs/mattermost-docker.nix
../2configs/nginx/euer.test.nix ../2configs/nginx/euer.test.nix
../2configs/nginx/public_html.nix
../2configs/nginx/update.connector.one.nix ../2configs/nginx/update.connector.one.nix
../2configs/deployment/mycube.connector.one.nix ../2configs/deployment/mycube.connector.one.nix
@ -31,7 +32,9 @@ in {
]; ];
services.smartd.devices = [ { device = "/dev/sda";} ]; services.smartd.devices = [ { device = "/dev/sda";} ];
###### stable ###### stable
services.nginx.virtualHosts.cgit.serverAliases = [ "cgit.euer.krebsco.de" ];
krebs.build.host = config.krebs.hosts.gum; krebs.build.host = config.krebs.hosts.gum;
krebs.tinc.retiolum = { krebs.tinc.retiolum = {
extraConfig = '' extraConfig = ''
@ -48,10 +51,6 @@ in {
makefu.taskserver.enable = true; makefu.taskserver.enable = true;
krebs.nginx.servers.cgit = {
server-names = [ "cgit.euer.krebsco.de" ];
listen = [ "${external-ip}:80" "${internal-ip}:80" ];
};
# access # access
users.users = { users.users = {
@ -76,9 +75,8 @@ in {
services.udev.extraRules = '' services.udev.extraRules = ''
SUBSYSTEM=="net", ATTR{address}=="c8:0a:a9:c8:ee:dd", NAME="et0" SUBSYSTEM=="net", ATTR{address}=="c8:0a:a9:c8:ee:dd", NAME="et0"
''; '';
boot.kernelParams = [ "ipv6.disable=1" ]; boot.kernelParams = [ ];
networking = { networking = {
enableIPv6 = false;
firewall = { firewall = {
allowPing = true; allowPing = true;
logRefusedConnections = false; logRefusedConnections = false;

View File

@ -48,12 +48,16 @@ in {
../2configs/exim-retiolum.nix ../2configs/exim-retiolum.nix
../2configs/smart-monitor.nix ../2configs/smart-monitor.nix
../2configs/mail-client.nix ../2configs/mail-client.nix
../2configs/disable_v6.nix # ../2configs/disable_v6.nix
#../2configs/graphite-standalone.nix #../2configs/graphite-standalone.nix
#../2configs/share-user-sftp.nix #../2configs/share-user-sftp.nix
../2configs/omo-share.nix ../2configs/omo-share.nix
../2configs/tinc/retiolum.nix ../2configs/tinc/retiolum.nix
../2configs/torrent.nix # ../2configs/torrent.nix
# ../2configs/elchos/search.nix
# ../2configs/elchos/log.nix
# ../2configs/elchos/irc-token.nix
## as long as pyload is not in nixpkgs: ## as long as pyload is not in nixpkgs:
# docker run -d -v /var/lib/pyload:/opt/pyload/pyload-config -v /media/crypt0/pyload:/opt/pyload/Downloads --name pyload --restart=always -p 8112:8000 -P writl/pyload # docker run -d -v /var/lib/pyload:/opt/pyload/pyload-config -v /media/crypt0/pyload:/opt/pyload/Downloads --name pyload --restart=always -p 8112:8000 -P writl/pyload
@ -121,7 +125,8 @@ in {
// { "/media/cryptX" = { // { "/media/cryptX" = {
device = (lib.concatMapStringsSep ":" (d: (toMapper d)) [ 0 1 2 ]); device = (lib.concatMapStringsSep ":" (d: (toMapper d)) [ 0 1 2 ]);
fsType = "mergerfs"; fsType = "mergerfs";
options = [ "defaults" "allow_other" ]; noCheck = true;
options = [ "defaults" "allow_other" "nofail" "nonempty" ];
}; };
}; };

View File

@ -21,7 +21,6 @@ in {
krebs = { krebs = {
enable = true; enable = true;
build.host = config.krebs.hosts.shoney; build.host = config.krebs.hosts.shoney;
nginx.enable = true;
tinc_graphs = { tinc_graphs = {
enable = true; enable = true;
network = "siem"; network = "siem";
@ -29,9 +28,15 @@ in {
nginx = { nginx = {
enable = true; enable = true;
# TODO: remove hard-coded hostname # TODO: remove hard-coded hostname
anonymous-domain = "localhost.localdomain";
anonymous.extraConfig = "return 403;";
complete = { complete = {
listen = [ "${tinc-siem-ip}:80" ]; serverAliases = [ "graphs.siem" ];
server-names = [ "graphs.siem" ]; extraConfig = ''
if ( $server_addr = "${ip}" ) {
return 403;
}
'';
}; };
}; };
}; };

View File

@ -21,9 +21,7 @@ in {
# other nginx # other nginx
../2configs/nginx/euer.wiki.nix ../2configs/nginx/euer.wiki.nix
../2configs/nginx/euer.blog.nix ../2configs/nginx/euer.blog.nix
../2configs/nginx/euer.test.nix # ../2configs/nginx/euer.test.nix
#../2configs/elchos/stats.nix
# collectd # collectd
# ../2configs/collectd/collectd-base.nix # ../2configs/collectd/collectd-base.nix
@ -47,26 +45,31 @@ in {
random-emoji ]; random-emoji ];
}; };
# bepasty to listen only on the correct interfaces
krebs.bepasty.servers.internal.nginx.listen = [ "${internal-ip}:80" ];
krebs.bepasty.servers.external.nginx.listen = [ "${external-ip}:80" "${external-ip}:443 ssl" ];
# prepare graphs # prepare graphs
krebs.nginx.enable = true; services.nginx.enable = true;
krebs.retiolum-bootstrap.enable = true; krebs.retiolum-bootstrap.enable = true;
krebs.bepasty.servers."paste.r".nginx.extraConfig = ''
if ( $server_addr = "${external-ip}" ) {
return 403;
}
'';
krebs.tinc_graphs = { krebs.tinc_graphs = {
enable = true; enable = true;
nginx = { nginx = {
enable = true; enable = true;
# TODO: remove hard-coded hostname # TODO: remove hard-coded hostname
complete = { complete = {
listen = [ "${internal-ip}:80" ]; extraConfig = ''
server-names = [ "graphs.wry" "graphs.retiolum" "graphs.wry.retiolum" ]; if ( $server_addr = "${external-ip}" ) {
return 403;
}
'';
serverAliases = [ "graphs.retiolum" "graphs.wry" "graphs.retiolum" "graphs.wry.retiolum" ];
}; };
anonymous = { anonymous = {
listen = [ "${external-ip}:80" ] ; enableSSL = true;
server-names = [ "graphs.krebsco.de" ]; forceSSL = true;
enableACME = true;
}; };
}; };
}; };

View File

@ -20,54 +20,29 @@ let
ext-dom = "paste.krebsco.de" ; ext-dom = "paste.krebsco.de" ;
in { in {
krebs.nginx.enable = mkDefault true; services.nginx.enable = mkDefault true;
krebs.bepasty = { krebs.bepasty = {
enable = true; enable = true;
serveNginx= true; serveNginx= true;
servers = { servers = {
internal = { "paste.r" = {
nginx = { nginx = {
server-names = [ "paste.retiolum" "paste.r" "paste.${config.krebs.build.host.name}" ]; serverAliases = [ "paste.retiolum" "paste.${config.krebs.build.host.name}" ];
}; };
defaultPermissions = "admin,list,create,read,delete"; defaultPermissions = "admin,list,create,read,delete";
secretKey = secKey; secretKey = secKey;
}; };
external = { "${ext-dom}" = {
nginx = { nginx = {
server-names = [ ext-dom ]; enableSSL = true;
ssl = { forceSSL = true;
enable = true; enableACME = true;
certificate = "${acmepath}/${ext-dom}/fullchain.pem";
certificate_key = "${acmepath}/${ext-dom}/key.pem";
# these certs will be needed if acme has not yet created certificates:
#certificate = "${sec}/wildcard.krebsco.de.crt";
#certificate_key = "${sec}/wildcard.krebsco.de.key";
ciphers = "RC4:HIGH:!aNULL:!MD5" ;
force_encryption = true;
};
locations = singleton ( nameValuePair "/.well-known/acme-challenge" ''
root ${acmechall}/${ext-dom}/;
'');
extraConfig = ''
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_verify_client off;
proxy_ssl_session_reuse off;
'';
}; };
defaultPermissions = "read"; defaultPermissions = "read";
secretKey = secKey; secretKey = secKey;
}; };
}; };
}; };
security.acme.certs."${ext-dom}" = {
email = "acme@syntax-fehler.de";
webroot = "${acmechall}/${ext-dom}/";
group = "nginx";
allowKeysForGroup = true;
postRun = "systemctl reload nginx.service";
extraDomains."${ext-dom}" = null ;
};
} }

View File

@ -22,7 +22,7 @@ with import <stockholm/lib>;
user = config.krebs.users.makefu; user = config.krebs.users.makefu;
source = let source = let
inherit (config.krebs.build) host user; inherit (config.krebs.build) host user;
ref = "f52eaf4"; # stable @ 2016-12-12 ref = "ee13b9af"; # stable @ 2016-12-12
in { in {
nixpkgs = if config.makefu.full-populate || (getEnv "dummy_secrets" == "true") then nixpkgs = if config.makefu.full-populate || (getEnv "dummy_secrets" == "true") then
{ {

View File

@ -27,23 +27,18 @@ in {
}; };
}; };
krebs.nginx = { services.nginx = {
enable = mkDefault true; enable = mkDefault true;
servers = { virtualHosts."mybox.connector.one" = {
mybox-connector-one = { locations = {
listen = [ "${external-ip}:80" ]; "/".extraConfig = ''
server-names = [
"mycube.connector.one"
"mybox.connector.one"
];
locations = singleton (nameValuePair "/" ''
uwsgi_pass unix://${wsgi-sock}; uwsgi_pass unix://${wsgi-sock};
uwsgi_param UWSGI_CHDIR ${pkgs.mycube-flask}/${pkgs.python.sitePackages}; uwsgi_param UWSGI_CHDIR ${pkgs.mycube-flask}/${pkgs.python.sitePackages};
uwsgi_param UWSGI_MODULE mycube.websrv; uwsgi_param UWSGI_MODULE mycube.websrv;
uwsgi_param UWSGI_CALLABLE app; uwsgi_param UWSGI_CALLABLE app;
include ${pkgs.nginx}/conf/uwsgi_params; include ${pkgs.nginx}/conf/uwsgi_params;
''); '';
}; };
}; };
}; };

View File

@ -1,4 +1,3 @@
{ {
networking.enableIPv6 = false; networking.enableIPv6 = false;
boot.kernelParams = [ "ipv6.disable=1" ];
} }

View File

@ -0,0 +1,56 @@
{ config, lib, pkgs, ... }:
with import <stockholm/lib>;
let
in {
networking.firewall.allowedTCPPorts = [ 80 443 514 ];
networking.firewall.allowedUDPPorts = [ 80 443 514 ];
services.logstash = {
enable = true;
enableWeb = true;
inputConfig = ''
syslog {
timezone => "Etc/UTC"
}
'';
filterConfig = ''
if ( [program] == "proftpd") {
kv {
field_split => " "
}
}
'';
outputConfig = ''
stdout {
codec => rubydebug
}
elasticsearch { }
'';
};
services.elasticsearch = {
enable = true;
};
services.kibana = {
enable = true;
port = 9332;
};
services.nginx = {
virtualHosts = {
"log.nsupdate.info" = {
enableACME = true;
forceSSL = true;
basicAuth = import <secrets/kibana-auth.nix>;
locations = {
"/" = {
proxyPass = "http://localhost:9332";
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
'';
};
};
};
};
};
}

View File

@ -1,11 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
# graphite-web on port 8080 # search also generates ddclient entries for all other logs
# carbon cache on port 2003 (tcp/udp)
with import <stockholm/lib>; with import <stockholm/lib>;
let let
#primary-itf = "eth0"; #primary-itf = "eth0";
primary-itf = "wlp2s0"; #primary-itf = "wlp2s0";
primary-itf = config.makefu.server.primary-itf;
elch-sock = "${config.services.uwsgi.runDir}/uwsgi-elch.sock"; elch-sock = "${config.services.uwsgi.runDir}/uwsgi-elch.sock";
ddclientUser = "ddclient"; ddclientUser = "ddclient";
sec = toString <secrets>; sec = toString <secrets>;
@ -14,15 +15,7 @@ let
cfg = "${stateDir}/cfg"; cfg = "${stateDir}/cfg";
ddclientPIDFile = "${stateDir}/ddclient.pid"; ddclientPIDFile = "${stateDir}/ddclient.pid";
acmepath = "/var/lib/acme/";
acmechall = acmepath + "/challenges/";
# TODO: correct cert generation requires a `real` internet ip address # TODO: correct cert generation requires a `real` internet ip address
stats-dom = "stats.nsupdate.info";
search-dom = "search.nsupdate.info";
search_ssl_cert = "${acmepath}/${search-dom}/fullchain.pem";
search_ssl_key = "${acmepath}/${search-dom}/key.pem";
stats_ssl_cert = "${acmepath}/${stats-dom}/fullchain.pem";
stats_ssl_key = "${acmepath}/${stats-dom}/key.pem";
gen-cfg = dict: '' gen-cfg = dict: ''
ssl=yes ssl=yes
@ -64,75 +57,22 @@ in {
}; };
}; };
security.acme.certs = { services.nginx = {
"${stats-dom}" = {
email = "acme@syntax-fehler.de";
webroot = "${acmechall}/${stats-dom}/";
group = "nginx";
allowKeysForGroup = true;
postRun = "systemctl reload nginx.service";
extraDomains = {
"${stats-dom}" = null ;
};
};
"${search-dom}" = {
email = "acme@syntax-fehler.de";
webroot = "${acmechall}/${search-dom}/";
group = "nginx";
allowKeysForGroup = true;
postRun = "systemctl reload nginx.service";
extraDomains = {
"${stats-dom}" = null ;
};
};
};
krebs.nginx = {
enable = mkDefault true; enable = mkDefault true;
servers = { virtualHosts = {
elch-stats = { "search.nsupdate.info" = {
server-names = [ stats-dom ]; enableACME = true;
# listen = [ "80" "443 ssl" ]; forceSSL = true;
ssl = { locations = {
enable = true; "/".extraConfig = ''
certificate = stats_ssl_cert; uwsgi_pass unix://${elch-sock};
certificate_key = stats_ssl_key; uwsgi_param UWSGI_CHDIR ${pkgs.elchhub}/${pkgs.python3.sitePackages};
force_encryption = true; uwsgi_param UWSGI_MODULE elchhub.wsgi;
}; uwsgi_param UWSGI_CALLABLE app;
locations = [ include ${pkgs.nginx}/conf/uwsgi_params;
(nameValuePair "/" '' '';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:3000/;
'')
(nameValuePair "/.well-known/acme-challenge" ''
root ${acmechall}/${search-dom}/;
'')
];
};
elchhub = {
server-names = [ "search.nsupdate.info" ];
# listen = [ "80" "443 ssl" ];
ssl = {
enable = true;
certificate = search_ssl_cert;
certificate_key = search_ssl_key;
force_encryption = true;
}; };
locations = [ (nameValuePair "/" ''
uwsgi_pass unix://${elch-sock};
uwsgi_param UWSGI_CHDIR ${pkgs.elchhub}/${pkgs.python3.sitePackages};
uwsgi_param UWSGI_MODULE elchhub.wsgi;
uwsgi_param UWSGI_CALLABLE app;
include ${pkgs.nginx}/conf/uwsgi_params;
'')
(nameValuePair "/.well-known/acme-challenge" ''
root ${acmechall}/${search-dom}/;
'')
];
}; };
}; };
}; };
@ -147,7 +87,7 @@ in {
ExecStart = "${pkgs.elchhub}/bin/elch-manager"; ExecStart = "${pkgs.elchhub}/bin/elch-manager";
}; };
}; };
register-elchos-nsupdate = { ddclient-nsupdate-elchos = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "ip-up.target" ]; after = [ "ip-up.target" ];
serviceConfig = { serviceConfig = {
@ -163,49 +103,8 @@ in {
}; };
}; };
services.grafana = {
enable = true;
addr = "127.0.0.1";
users.allowSignUp = false;
users.allowOrgCreate = false;
users.autoAssignOrg = false;
auth.anonymous.enable = true;
security = import <secrets/grafana_security.nix>; # { AdminUser = ""; adminPassword = ""}
};
services.graphite = {
api = {
enable = true;
listenAddress = "127.0.0.1";
port = 8080;
};
carbon = {
enableCache = true;
# save disk usage by restricting to 1 bulk update per second
config = ''
[cache]
MAX_CACHE_SIZE = inf
MAX_UPDATES_PER_SECOND = 1
MAX_CREATES_PER_MINUTE = 500
'';
storageSchemas = ''
[carbon]
pattern = ^carbon\.
retentions = 60:90d
[elchos]
patterhn = ^elchos\.
retentions = 10s:30d,60s:3y
[default]
pattern = .*
retentions = 30s:30d,300s:1y
'';
};
};
networking.firewall = { networking.firewall = {
allowedTCPPorts = [ 2003 80 443 ]; allowedTCPPorts = [ 80 443 ];
allowedUDPPorts = [ 2003 ]; allowedUDPPorts = [ ];
}; };
} }

View File

@ -1,73 +1,48 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
# requires nsupdate to get correct hostname (from ./search.nix)
# graphite-web on port 8080 # graphite-web on port 8080
# carbon cache on port 2003 (tcp/udp) # carbon cache on port 2003 (tcp/udp)
with import <stockholm/lib>; with import <stockholm/lib>;
let {
sec = toString <secrets>;
acmepath = "/var/lib/acme/"; services.nginx = {
acmechall = acmepath + "/challenges/"; enable = mkDefault true;
ext-dom = "stats.nsupdate.info"; virtualHosts = {
#ssl_cert = "${sec}/wildcard.krebsco.de.crt"; "stats.nsupdate.info" = {
#ssl_key = "${sec}/wildcard.krebsco.de.key"; enableACME = true;
ssl_cert = "${acmepath}/${ext-dom}/fullchain.pem"; forceSSL = true;
ssl_key = "${acmepath}/${ext-dom}/key.pem";
in { locations = {
networking.firewall = { "/" = {
allowedTCPPorts = [ 2003 80 443 ]; proxyPass = "http://localhost:3000/";
allowedUDPPorts = [ 2003 ]; extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
'';
};
};
};
};
}; };
services.grafana = { services.grafana = {
enable = true; enable = true;
addr = "127.0.0.1"; addr = "127.0.0.1";
extraOptions = { "AUTH_ANONYMOUS_ENABLED" = "true"; };
users.allowSignUp = false; users.allowSignUp = false;
users.allowOrgCreate = false; users.allowOrgCreate = false;
users.autoAssignOrg = false; users.autoAssignOrg = false;
auth.anonymous.enable = true;
security = import <secrets/grafana_security.nix>; # { AdminUser = ""; adminPassword = ""} security = import <secrets/grafana_security.nix>; # { AdminUser = ""; adminPassword = ""}
}; };
krebs.nginx = {
enable = true;
servers.elch-stats = {
server-names = [ ext-dom ];
listen = [ "80" "443 ssl" ];
ssl = {
enable = true;
# these certs will be needed if acme has not yet created certificates:
certificate = ssl_cert;
certificate_key = ssl_key;
force_encryption = true;
};
locations = [
(nameValuePair "/" ''
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:3000/;
'')
(nameValuePair "/.well-known/acme-challenge" ''
root ${acmechall}/${ext-dom}/;
'')
];
};
};
security.acme.certs."${ext-dom}" = {
email = "acme@syntax-fehler.de";
webroot = "${acmechall}/${ext-dom}/";
group = "nginx";
allowKeysForGroup = true;
postRun = "systemctl reload nginx.service";
extraDomains."${ext-dom}" = null ;
};
services.graphite = { services.graphite = {
web = { api = {
enable = true; enable = true;
host = "127.0.0.1"; listenAddress = "127.0.0.1";
port = 8080; port = 18080;
}; };
carbon = { carbon = {
enableCache = true; enableCache = true;
@ -85,7 +60,7 @@ in {
[elchos] [elchos]
patterhn = ^elchos\. patterhn = ^elchos\.
retention = 10s:30d,60s:1y retentions = 10s:30d,60s:3y
[default] [default]
pattern = .* pattern = .*
@ -93,4 +68,9 @@ in {
''; '';
}; };
}; };
networking.firewall = {
allowedTCPPorts = [ 2003 80 443 ];
allowedUDPPorts = [ 2003 ];
};
} }

View File

@ -0,0 +1,7 @@
{...}:
{
services.vsftpd.anonymousUser = true;
services.vsftpd.enable = true;
services.vsftpd.chrootlocalUser = true;
networking.firewall.allowedTCPPorts = [ 21 ];
}

View File

@ -71,5 +71,15 @@ in {
latitude = "48.7"; latitude = "48.7";
longitude = "9.1"; longitude = "9.1";
}; };
systemd.services.look-up = {
startAt = "*:30";
serviceConfig = {
ExecStart= pkgs.writeDash "look-up" ''
set -x
eval "export '$(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(${pkgs.procps}/bin/pgrep -u ${user} ${window-manager})/environ)'"
${pkgs.libnotify}/bin/notify-send -u critical -t 9999999 'look up once in a while'
'';
User = user;
};
};
} }

View File

@ -3,13 +3,9 @@
with import <stockholm/lib>; with import <stockholm/lib>;
let let
sec = toString <secrets>; sec = toString <secrets>;
ssl_cert = "${sec}/wildcard.krebsco.de.crt";
ssl_key = "${sec}/wildcard.krebsco.de.key";
hostname = config.krebs.build.host.name; hostname = config.krebs.build.host.name;
user = config.services.nginx.user; user = config.services.nginx.user;
group = config.services.nginx.group; group = config.services.nginx.group;
external-ip = config.krebs.build.host.nets.internet.ip4.addr;
internal-ip = config.krebs.build.host.nets.retiolum.ip4.addr;
base-dir = "/var/www/blog.euer"; base-dir = "/var/www/blog.euer";
in { in {
# Prepare Blog directory # Prepare Blog directory
@ -32,24 +28,15 @@ in {
}; };
}; };
krebs.nginx = { services.nginx = {
enable = mkDefault true; enable = mkDefault true;
servers = { virtualHosts = {
euer-blog = { "euer.krebsco.de" = {
listen = [ "${external-ip}:80" "${external-ip}:443 ssl" #serverAliases = [ "blog.euer.krebsco.de" "blog.${hostname}" ];
"${internal-ip}:80" "${internal-ip}:443 ssl" ]; enableSSL = true;
server-names = [ "euer.krebsco.de" "blog.euer.krebsco.de" "blog.${hostname}" ]; enableACME = true;
extraConfig = '' forceSSL = true;
gzip on; root = base-dir;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/css;
ssl_certificate ${ssl_cert};
ssl_certificate_key ${ssl_key};
default_type text/plain;
'';
locations = singleton (nameValuePair "/" ''
root ${base-dir};
'');
}; };
}; };
}; };

View File

@ -8,18 +8,16 @@ let
external-ip = config.krebs.build.host.nets.internet.ip4.addr; external-ip = config.krebs.build.host.nets.internet.ip4.addr;
internal-ip = config.krebs.build.host.nets.retiolum.ip4.addr; internal-ip = config.krebs.build.host.nets.retiolum.ip4.addr;
in { in {
krebs.nginx = { services.nginx = {
enable = mkDefault true; enable = mkDefault true;
servers = { virtualHosts."share.euer.krebsco.de" = {
euer-share = { locations."/" = {
listen = [ ]; proxyPass = "http://localhost:8000/";
server-names = [ "share.euer.krebsco.de" ]; extraConfig = ''
locations = singleton (nameValuePair "/" ''
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8000/; '';
'');
}; };
}; };
}; };

View File

@ -4,13 +4,6 @@ with import <stockholm/lib>;
let let
sec = toString <secrets>; sec = toString <secrets>;
ext-dom = "wiki.euer.krebsco.de"; ext-dom = "wiki.euer.krebsco.de";
acmepath = "/var/lib/acme/";
acmechall = acmepath + "/challenges/";
#ssl_cert = "${sec}/wildcard.krebsco.de.crt";
#ssl_key = "${sec}/wildcard.krebsco.de.key";
ssl_cert = "${acmepath}/${ext-dom}/fullchain.pem";
ssl_key = "${acmepath}/${ext-dom}/key.pem";
user = config.services.nginx.user; user = config.services.nginx.user;
group = config.services.nginx.group; group = config.services.nginx.group;
@ -25,8 +18,7 @@ let
# user1 = pass1 # user1 = pass1
# userN = passN # userN = passN
tw-pass-file = "${sec}/tw-pass.ini"; tw-pass-file = "${sec}/tw-pass.ini";
external-ip = config.krebs.build.host.nets.internet.ip4.addr;
internal-ip = config.krebs.build.host.nets.retiolum.ip4.addr;
in { in {
services.phpfpm = { services.phpfpm = {
# phpfpm does not have an enable option # phpfpm does not have an enable option
@ -79,24 +71,18 @@ in {
}; };
}; };
krebs.nginx = { services.nginx = {
enable = mkDefault true; enable = mkDefault true;
servers = { virtualHosts = {
euer-wiki = { "${ext-dom}" = {
listen = [ "${external-ip}:80" "${external-ip}:443 ssl" #serverAliases = [
"${internal-ip}:80" "${internal-ip}:443 ssl" ]; # "wiki.makefu.retiolum"
server-names = [ # "wiki.makefu"
ext-dom #];
"wiki.makefu.retiolum" enableSSL = true;
"wiki.makefu" forceSSL = true;
]; enableACME = true;
ssl = { # recommendedGzipSettings = true;
enable = true;
# these certs will be needed if acme has not yet created certificates:
certificate = ssl_cert;
certificate_key = ssl_key;
force_encryption = true;
};
extraConfig = '' extraConfig = ''
gzip on; gzip on;
gzip_buffers 4 32k; gzip_buffers 4 32k;
@ -104,34 +90,26 @@ in {
default_type text/plain; default_type text/plain;
''; '';
locations = [ locations = {
(nameValuePair "/" '' "/" = {
root ${wiki-dir}; root = wiki-dir;
expires -1; extraConfig = ''
autoindex on; expires -1;
'') autoindex on;
(nameValuePair "/store.php" '' '';
root ${tw-upload}; };
client_max_body_size 200M; "/store.php" = {
fastcgi_split_path_info ^(.+\.php)(/.+)$; root = tw-upload;
fastcgi_pass unix:${fpm-socket}; extraConfig = ''
include ${pkgs.nginx}/conf/fastcgi_params; client_max_body_size 200M;
include ${pkgs.nginx}/conf/fastcgi.conf; fastcgi_split_path_info ^(.+\.php)(/.+)$;
'') fastcgi_pass unix:${fpm-socket};
(nameValuePair "/.well-known/acme-challenge" '' include ${pkgs.nginx}/conf/fastcgi_params;
root ${acmechall}/${ext-dom}/; include ${pkgs.nginx}/conf/fastcgi.conf;
'') '';
};
]; };
}; };
}; };
}; };
security.acme.certs."${ext-dom}" = {
email = "acme@syntax-fehler.de";
webroot = "${acmechall}/${ext-dom}/";
group = "nginx";
allowKeysForGroup = true;
postRun = "systemctl reload nginx.service";
extraDomains."${ext-dom}" = null ;
};
} }

View File

@ -10,19 +10,17 @@ let
sha256 = "0l8q7kw3w1kpvmy8hza9vr5liiycivbljkmwpacaifbay5y98z58"; sha256 = "0l8q7kw3w1kpvmy8hza9vr5liiycivbljkmwpacaifbay5y98z58";
}; };
in{ in{
krebs.nginx = { services.nginx = {
enable = true; enable = true;
servers.default = { virtualHosts.default = {
extraConfig = '' root = "${icecult}/app";
root ${icecult}/app; locations = {
"/rpc".proxyPass = "http://10.42.22.163:3121";
"/rpc".extraConfig = ''
rewrite /rpc/(.*) /$1 break;
proxy_http_version 1.1;
''; '';
locations = [ };
(nameValuePair "/rpc" ''
rewrite /rpc/(.*) /$1 break;
proxy_http_version 1.1;
proxy_pass http://10.42.22.163:3121;
'')
];
}; };
}; };
} }

View File

@ -3,13 +3,16 @@
with import <stockholm/lib>; with import <stockholm/lib>;
{ {
krebs.nginx = { services.nginx = {
enable = true; enable = true;
servers.default.locations = [ virtualHosts.default = {
(nameValuePair "~ ^/~(.+?)(/.*)?\$" '' default = true;
alias /home/$1/public_html$2; locations = {
autoindex on; "~ ^/~(.+?)(/.*)?\$".extraConfig = ''
'') alias /home/$1/public_html$2;
]; autoindex on;
'';
};
};
}; };
} }

View File

@ -1,25 +1,19 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with import <stockholm/lib>; with import <stockholm/lib>;
let {
hostname = config.krebs.build.host.name; services.nginx = {
external-ip = config.krebs.build.host.nets.internet.ip4.addr;
in {
krebs.nginx = {
enable = mkDefault true; enable = mkDefault true;
servers = { virtualHosts."update.connector.one" = {
update-connector-one = { locations = {
listen = [ "${external-ip}:80" ]; "/" = {
server-names = [ root = "/var/www/update.connector.one";
"update.connector.one" extraConfig = ''
"firmware.connector.one" autoindex on;
]; sendfile on;
locations = singleton (nameValuePair "/" '' gzip on;
autoindex on; '';
root /var/www/update.connector.one; };
sendfile on;
gzip on;
'');
}; };
}; };
}; };

View File

@ -7,38 +7,6 @@ let
local-ip = "192.168.1.11"; local-ip = "192.168.1.11";
# local-ip = config.krebs.build.host.nets.retiolum.ip4.addr; # local-ip = config.krebs.build.host.nets.retiolum.ip4.addr;
in { in {
krebs.nginx = {
enable = mkDefault true;
servers = {
omo-share = {
listen = [ "${local-ip}:80" ];
locations = singleton (nameValuePair "/" ''
access_log off;
# sendfile off;
# tcp_nopush on;
# aio on;
sendfile on;
sendfile_max_chunk 512k;
directio 512;
mp4;
autoindex on;
root /media;
limit_rate_after 100m;
limit_rate 5m;
mp4_buffer_size 4M;
mp4_max_buffer_size 10M;
allow all;
access_log off;
keepalive_timeout 65;
keepalive_requests 200;
reset_timedout_connection on;
tcp_nopush on;
gzip off;
'');
};
};
};
# samba share /media/crypt1/share # samba share /media/crypt1/share
users.users.smbguest = { users.users.smbguest = {
@ -68,6 +36,12 @@ in {
browseable = "yes"; browseable = "yes";
"guest ok" = "yes"; "guest ok" = "yes";
}; };
pyload = {
path = "/media/crypt0/pyload";
"read only" = "yes";
browseable = "yes";
"guest ok" = "yes";
};
crypt0-rw = { crypt0-rw = {
path = "/media/crypt0/"; path = "/media/crypt0/";
"read only" = "no"; "read only" = "no";