2018-11-26 23:05:45 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2023-09-03 14:13:37 +02:00
|
|
|
|
2023-07-02 16:05:52 +02:00
|
|
|
with pkgs.stockholm.lib;
|
2018-11-26 23:05:45 +01:00
|
|
|
let
|
2018-11-28 17:00:39 +01:00
|
|
|
ident = (builtins.readFile ./auphonic.pub);
|
2023-09-03 14:13:37 +02:00
|
|
|
nginxlogs = "/var/log/nginx";
|
|
|
|
bgtaccess = "${nginxlogs}/binaergewitter.access.log";
|
|
|
|
bgterror = "${nginxlogs}/binaergewitter.error.log";
|
2022-06-06 21:12:52 +02:00
|
|
|
|
|
|
|
# TODO: only when the data is stored somewhere else
|
|
|
|
wwwdir = "/var/www/binaergewitter";
|
|
|
|
storedir = "/media/cloud/www/binaergewitter";
|
2018-11-26 23:05:45 +01:00
|
|
|
in {
|
2023-09-03 14:13:37 +02:00
|
|
|
state = [ bgtaccess bgterror ];
|
|
|
|
|
2022-06-06 21:12:52 +02:00
|
|
|
fileSystems."${wwwdir}" = {
|
|
|
|
device = storedir;
|
|
|
|
options = [ "bind" ];
|
2023-07-09 17:40:17 +02:00
|
|
|
depends = [ "/media/cloud" ];
|
2022-06-06 21:12:52 +02:00
|
|
|
};
|
|
|
|
|
2018-11-28 17:00:39 +01:00
|
|
|
services.openssh = {
|
|
|
|
allowSFTP = true;
|
|
|
|
sftpFlags = [ "-l VERBOSE" ];
|
|
|
|
extraConfig = ''
|
2022-06-06 21:12:52 +02:00
|
|
|
HostkeyAlgorithms +ssh-rsa
|
|
|
|
|
2018-11-28 17:00:39 +01:00
|
|
|
Match User auphonic
|
|
|
|
ForceCommand internal-sftp
|
|
|
|
AllowTcpForwarding no
|
|
|
|
X11Forwarding no
|
|
|
|
PasswordAuthentication no
|
2022-06-06 21:12:52 +02:00
|
|
|
PubkeyAcceptedAlgorithms +ssh-rsa
|
|
|
|
|
2018-11-28 17:00:39 +01:00
|
|
|
'';
|
|
|
|
};
|
2020-11-18 19:37:33 +01:00
|
|
|
|
2018-11-28 17:00:39 +01:00
|
|
|
users.users.auphonic = {
|
|
|
|
uid = genid "auphonic";
|
|
|
|
group = "nginx";
|
2022-06-06 21:12:52 +02:00
|
|
|
# for storedir
|
|
|
|
extraGroups = [ "download" ];
|
2018-11-28 17:00:39 +01:00
|
|
|
useDefaultShell = true;
|
2021-06-05 15:08:59 +02:00
|
|
|
isSystemUser = true;
|
2018-11-28 17:00:39 +01:00
|
|
|
openssh.authorizedKeys.keys = [ ident config.krebs.users.makefu.pubkey ];
|
2018-11-26 23:05:45 +01:00
|
|
|
};
|
2020-11-18 19:37:33 +01:00
|
|
|
|
2018-12-31 10:17:15 +01:00
|
|
|
services.logrotate = {
|
|
|
|
enable = true;
|
2022-12-12 20:00:20 +01:00
|
|
|
settings.bgt = {
|
|
|
|
files = [ bgtaccess bgterror ];
|
|
|
|
rotate = 5;
|
|
|
|
frequency = "weekly";
|
|
|
|
create = "600 nginx nginx";
|
|
|
|
postrotate = "${pkgs.systemd}/bin/systemctl reload nginx";
|
|
|
|
};
|
2018-12-31 10:17:15 +01:00
|
|
|
};
|
2020-11-18 13:42:16 +01:00
|
|
|
|
|
|
|
# 20.09 unharden nginx to write logs
|
2023-09-03 14:13:37 +02:00
|
|
|
systemd.services.nginx.serviceConfig.ReadWritePaths = [ nginxlogs ];
|
|
|
|
systemd.tmpfiles.rules = [ "d ${nginxlogs} 0700 nginx root - -" ];
|
|
|
|
|
2023-07-02 17:09:35 +02:00
|
|
|
sops.secrets."lego-binaergewitter" = {};
|
2022-08-29 21:12:21 +02:00
|
|
|
security.acme.certs."download.binaergewitter.de" = {
|
|
|
|
dnsProvider = "cloudflare";
|
2023-07-02 17:09:35 +02:00
|
|
|
credentialsFile = config.sops.secrets."lego-binaergewitter".path;
|
2022-08-29 21:12:21 +02:00
|
|
|
webroot = lib.mkForce null;
|
|
|
|
};
|
2020-11-18 19:37:33 +01:00
|
|
|
|
2018-11-26 23:05:45 +01:00
|
|
|
services.nginx = {
|
|
|
|
enable = lib.mkDefault true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
virtualHosts."download.binaergewitter.de" = {
|
2022-09-23 23:39:10 +02:00
|
|
|
addSSL = true;
|
2022-08-29 21:12:21 +02:00
|
|
|
enableACME = true;
|
2023-09-03 14:13:37 +02:00
|
|
|
serverAliases = [ "binaergewitter.jit.computer" "podcast.savar.de" "dl2.binaergewitter.de" ];
|
2018-11-26 23:05:45 +01:00
|
|
|
root = "/var/www/binaergewitter";
|
|
|
|
extraConfig = ''
|
2018-12-31 10:17:15 +01:00
|
|
|
access_log ${bgtaccess} combined;
|
|
|
|
error_log ${bgterror} error;
|
2018-11-26 23:05:45 +01:00
|
|
|
autoindex on;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|