feat: step ca for nextcloud

This commit is contained in:
DACHXY 2025-04-26 21:09:10 +08:00
parent b655f6ad4e
commit d6e8e23d3b
7 changed files with 110 additions and 45 deletions

View file

@ -37,4 +37,21 @@
ARRAY /dev/md126 metadata=1.2 name=stuff:0
UUID=b75dc506-8f7c-4557-8b2f-adb5f1358dbc
'';
fileSystems."/mnt/ssd" = {
device = "/dev/disk/by-uuid/4E21-0000";
fsType = "exfat";
options = [
"x-systemd.automount"
"noauto"
"x-systemd.idle-timeout=600"
"nofail"
"user"
"x-gvfs-show"
"gid=1000"
"uid=1000"
"dmask=000"
"fmask=000"
];
};
}

View file

@ -0,0 +1,29 @@
{ pkgs, ... }:
{
systemd.timers."certbot-renew" = {
enable = true;
description = "certbot renew";
timerConfig = {
OnCalendar = "*-*-* 03:00:00";
Persistent = true;
OnUnitActiveSec = "1d";
Unit = "certbot-renew.service";
};
wantedBy = [ "timers.target" ];
};
systemd.services."certbot-renew" = {
enable = true;
after = [
"nginx.service"
"network.target"
];
wantedBy = [ "multi-user.target" ];
environment = {
"REQUESTS_CA_BUNDLE" = "/var/lib/step-ca/certs/root_ca.crt";
};
serviceConfig = {
ExecStart = "${pkgs.certbot}/bin/certbot renew";
};
};
}

View file

@ -18,7 +18,8 @@
./services.nix
./nginx.nix
./nextcloud.nix
# ./step-ca.nix
./step-ca.nix
./cerbot.nix
../../modules/presets/minimal.nix
../../modules/bluetooth.nix
../../modules/cuda.nix

View file

@ -4,6 +4,19 @@
lib,
...
}:
let
acmeWebRoot = "/var/www/nextcloud.net.dn/html/";
certScript = pkgs.writeShellScriptBin "certbot-nextcloud" ''
${pkgs.certbot}/bin/certbot certonly --webroot \
--webroot-path ${acmeWebRoot} -v \
-d nextcloud.net.dn \
--server https://ca.net.dn:8443/acme/acme/directory \
-m admin@mail.net.dn
chown nginx:nginx -R /etc/letsencrypt
'';
in
{
imports = [
"${
@ -97,6 +110,41 @@
exiftool
];
services.nginx = {
virtualHosts = {
${config.services.nextcloud.hostName} = {
listen = lib.mkForce [
{
addr = "0.0.0.0";
port = 443;
ssl = true;
}
{
addr = "0.0.0.0";
port = 80;
}
];
locations."^~ /.well-known/acme-challenge/" = {
root = "/var/www/nextcloud.net.dn/html";
extraConfig = ''
default_type "text/plain";
'';
};
forceSSL = true;
sslCertificate = "/etc/letsencrypt/live/nextcloud.net.dn/fullchain.pem";
sslCertificateKey = "/etc/letsencrypt/live/nextcloud.net.dn/privkey.pem";
extraConfig = ''
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
'';
};
};
};
systemd.timers."nextcloud-backup" = {
enable = true;
description = "Nextcloud backup";
@ -148,4 +196,5 @@
"${script}/bin/backup";
};
};
}

View file

@ -1,30 +1,8 @@
{
config,
lib,
...
}:
{
services.nginx = {
enable = true;
virtualHosts = {
${config.services.nextcloud.hostName} = {
listen = lib.mkForce [
{
addr = "0.0.0.0";
port = 443;
ssl = true;
}
];
forceSSL = true;
sslCertificate = "/var/lib/acme/net.dn.crt";
sslCertificateKey = "/var/lib/acme/net.dn.key";
sslTrustedCertificate = "/var/lib/acme/net.dn.crt";
extraConfig = ''
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
'';
};
};
};
}

View file

@ -28,8 +28,7 @@ Bq-3sY8n13Dv0E6yx2hVIAlzLj3aE29LC4A2j81vW5MtpaM27lMpg.cwlqZ-8l1iZNeeS9.idRpRJ9zB
kty = "EC";
use = "sig";
x = "o-Srd0v3IY7zU9U2COE9BOsjyIPjBvNT2WKPTo8ePZI";
y = "y5OFjciRMVg8ePaEsjSPWbKp_
NjQ6U4CtbplRx7z3Bw";
y = "y5OFjciRMVg8ePaEsjSPWbKp_NjQ6U4CtbplRx7z3Bw";
};
name = "danny@smallstep.net.dn";
type = "JWK";
@ -46,8 +45,7 @@ NjQ6U4CtbplRx7z3Bw";
}
];
};
crt = "/var/lib/s
tep-ca/certs/intermediate_ca.crt";
crt = "/var/lib/step-ca/certs/intermediate_ca.crt";
db = {
badgerFileLoadingMode = "";
dataSource = "/var/lib/step-ca/db";
@ -67,8 +65,7 @@ tep-ca/certs/intermediate_ca.crt";
tls = {
cipherSuites = [
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"
"TLS_EC
DHE_ECDSA_WITH_AES_128_GCM_SHA256"
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
];
maxVersion = 1.3;
minVersion = 1.2;