{ imports = [ ./base.nix ./acme.nix { services.nginx.enable = true; } # acme currently uses nginx (but doesn't need it) ../../configs/retiolum.nix ../../configs/fail2ban.nix # DNS server configuration { # requires acme tv.unbound.enable = true; tv.unbound.DoH.enable = true; tv.unbound.DoT.enable = true; tv.unbound.host = "ns2.viljetic.de"; tv.unbound.useACMEHost = "viljetic.de"; } # SSH configuration ({ config, options, lib, pkgs, ... }: { services.openssh = { enable = true; allowSFTP = false; # mkForce to prevent duplicate keys hostKeys = lib.mkForce (lib.singleton ({ type = "ed25519"; path = "${config.krebs.secret.directory}/ssh.id_ed25519"; })); # macs and moduliFile are also in configs/sshd.nix settings.Macs = let default-macs = (options.services.openssh.settings.type.getSubOptions throw) .Macs.default; mac-blacklist = ["hmac-sha2-512" "hmac-sha2-256" "umac-128@openssh.com"]; in builtins.filter (mac: !builtins.elem mac mac-blacklist) default-macs; # "All Diffie-Hellman moduli in use should be at least 3072-bit-long" # Refs https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67 moduliFile = pkgs.runCommand "ssh-moduli" {} '' awk '$5 >= 3017' ${config.programs.ssh.package}/etc/ssh/moduli > $out ''; }; # Exempt these interfaces from configs/sshd.nix's port 22 redirect, # which would also catch forwarded ssh. # This is also required to access rut.jane. hrm.nftables.tables.nat.chains.prerouting.rules.ssh-interfaces = { order = 800; text = ''iifname { "lo", "retiolum", "wiregrill" } accept''; }; }) ({ config, ... }: { hrm.nftables.enable = true; krebs.build.host = config.krebs.hosts.ne; }) ({ pkgs, ... }: { boot.kernelPackages = pkgs.linuxPackages_latest; }) ../../configs/networkd.nix { networking.interfaces.ens3.useDHCP = true; networking.nameservers = [ "127.0.0.1" ]; } # IPv6 configuration ({ config, ... }: { networking.defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; networking.interfaces.ens3.ipv6.addresses = [ { address = config.krebs.build.host.nets.internet.ip6.addr; prefixLength = config.krebs.build.host.nets.internet.ip6.prefixLength; } ]; tv.iptables.extra6.filter.INPUT = [ # Allow Neighbor Discovery # https://en.wikipedia.org/wiki/Neighbor_Discovery_Protocol "-p icmpv6 --icmpv6-type 133 -j ACCEPT" "-p icmpv6 --icmpv6-type 134 -j ACCEPT" "-p icmpv6 --icmpv6-type 135 -j ACCEPT" "-p icmpv6 --icmpv6-type 136 -j ACCEPT" ]; }) # wiregrill configuration # requires secret: wiregrill.key # see also stockholm's kartei/tv/hosts/ne.nix ({ config, ... }: { imports = [ ../../configs/wiregrill.nix ]; boot.kernel.sysctl."net.ipv4.ip_forward" = 1; tv.iptables.extra4.nat.POSTROUTING = [ "-s 10.244.3.0/24 ! -d 10.244.3.0/24 -j MASQUERADE" ]; tv.iptables.extra6.nat.POSTROUTING = [ "-s 42:1::/32 ! -d 42:1::/32 -j MASQUERADE" ]; tv.iptables.extra6.filter.FORWARD = [ "-s ${config.krebs.hosts.pi.nets.wiregrill.ip6.addr} -j ACCEPT" "-s 42:1:a46e::/48 -j ACCEPT" # tv ]; tv.iptables.extra4.filter.FORWARD = [ "-i wiregrill -o wiregrill -j ACCEPT" "-i wiregrill -o retiolum -j ACCEPT" "-i retiolum -o wiregrill -j ACCEPT" ]; }) # Nginx configuration ({ lib, ... }: { imports = [ ../../configs/nginx ]; services.nginx.enable = true; services.nginx.appendHttpConfig = '' map $sent_http_content_type $charset { ~^text/ utf-8; } charset $charset; charset_types *; ''; services.nginx.commonHttpConfig = '' add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload' always; ''; tv.iptables.input-internet-accept-tcp = [ "http" "https" ]; # 2025/10/23 12:21:08 [alert] 2056944#2056944: 512 worker_connections are not enough services.nginx.eventsConfig = '' worker_connections 2048; ''; # Oct 23 15:41:42 ni nginx[2658928]: 2025/10/23 15:41:42 [alert] 2658928#2658928: *27810 socket() failed (24: Too many open files) while connecting to upstream, client: ::1, server: cgit, request: "GET ... HTTP/1.0", upstream: "fastcgi://unix:/run/fcgiwrap-cgit.sock:", host: "cgit" # Oct 23 15:41:42 ni nginx[2658928]: 2025/10/23 15:41:42 [crit] 2658928#2658928: accept4() failed (24: Too many open files) # cat /proc/$(pgrep -u nginx nginx | head -n 1)/limits | grep --color -C 100 '^Max open files .*' systemd.services.nginx.serviceConfig = { LimitNOFILE = 4096; }; }) # Nginx configuration: public_html (let locations."~ ^/~([a-z]+)(?:/(.*))?\$" = { alias = "/srv/$1/public_html/$2"; }; in { services.nginx.virtualHosts."ne.r".locations = locations; services.nginx.virtualHosts."viljetic.de".locations = locations; services.nginx.virtualHosts."ne.krebsco.de".locations = locations; }) # Nginx configuration: viljetic-pages ({ pkgs, ... }: { services.nginx.virtualHosts."viljetic.de" = { useACMEHost = "viljetic.de"; forceSSL = true; root = pkgs.viljetic-pages; }; services.nginx.virtualHosts."www.viljetic.de" = { useACMEHost = "viljetic.de"; forceSSL = true; locations."/".return = "301 $scheme://viljetic.de$request_uri"; }; }) # Nginx configuration: ne.krebsco.de { security.acme.certs."ne.krebsco.de".email = "tv@krebsco.de"; services.nginx.virtualHosts."ne.krebsco.de" = { enableACME = true; forceSSL = true; }; } # Git configuration # depends on nginx ({ config, lib, ... }: { imports = [ ../../configs/gitrepos.nix ]; services.nginx.virtualHosts."cgit.viljetic.de" = { serverAliases = [ "cgit.ne.viljetic.de" ]; useACMEHost = "viljetic.de"; forceSSL = true; locations."/".extraConfig = '' proxy_set_header Host cgit; proxy_pass http://localhost; ''; }; security.acme.certs."cgit.krebsco.de".email = "tv@krebsco.de"; services.nginx.virtualHosts."cgit.krebsco.de" = { serverAliases = [ "cgit.ne.krebsco.de" ]; enableACME = true; forceSSL = true; locations."/".extraConfig = '' proxy_set_header Host cgit; proxy_pass http://localhost; ''; }; # secrets ne gencert cgit.ne.r hrm.systemd.services.nginx.reloadIfCredentialsChange = true; systemd.services.nginx.serviceConfig.LoadCredential = [ "cgit.ne.r.crt:${config.krebs.secret.directory}/cgit.ne.r.crt" "cgit.ne.r.key:${config.krebs.secret.directory}/cgit.ne.r.key" ]; services.nginx.virtualHosts."cgit.ne.r" = { onlySSL = true; sslCertificate = "/run/credentials/nginx.service/cgit.ne.r.crt"; sslCertificateKey = "/run/credentials/nginx.service/cgit.ne.r.key"; locations."/".extraConfig = '' proxy_set_header Host cgit; proxy_pass http://localhost; ''; }; }) ]; }