1
0
Fork 0

redlib: switch from libreddit

This commit is contained in:
Daniel Kempkens 2023-12-28 13:55:57 +01:00
parent a6e409e0d4
commit 8f8d09a67e
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
3 changed files with 86 additions and 49 deletions

View file

@ -41,7 +41,7 @@ in
../nixos/invidious.nix ../nixos/invidious.nix
(import ../nixos/libreddit.nix (args // { inherit secret; })) (import ../nixos/redlib.nix (args // { inherit secret; }))
../nixos/linkding.nix ../nixos/linkding.nix

View file

@ -1,48 +0,0 @@
{ secret, ... }:
{
services.libreddit = {
enable = true;
address = "127.0.0.1";
port = 8002;
};
services.nginx.virtualHosts."${secret.nginx.hostnames.libreddit}" = {
# listen = [
# {
# addr = "100.64.10.2";
# port = 443;
# ssl = true;
# extraParameters = [
# "fastopen=63"
# "backlog=1023"
# "deferred"
# ];
# }
#
# {
# addr = "[fd7a:115c:a1e0:1010::2]";
# port = 443;
# ssl = true;
# extraParameters = [
# "fastopen=63"
# "backlog=1023"
# ];
# }
# ];
listenAddresses = [ "100.64.10.2" "[fd7a:115c:a1e0:1010::2]" ];
quic = true;
http3 = true;
onlySSL = true;
useACMEHost = "daniel.sx";
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:8002";
};
};
}

85
system/nixos/redlib.nix Normal file
View file

@ -0,0 +1,85 @@
{ pkgs, lib, secret, ... }:
{
systemd.services.redlib =
let
args = lib.concatStringsSep " " ([
"--port 8002"
"--address 127.0.0.1"
]);
in
{
description = "Private front-end for Reddit";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
DynamicUser = true;
ExecStart = "${pkgs.redlib}/bin/redlib ${args}";
Restart = "on-failure";
RestartSec = "2s";
# Hardening
CapabilityBoundingSet = [ "" ];
DeviceAllow = [ "" ];
LockPersonality = true;
MemoryDenyWriteExecute = true;
PrivateDevices = true;
# A private user cannot have process capabilities on the host's user
# namespace and thus CAP_NET_BIND_SERVICE has no effect.
PrivateUsers = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "~@privileged" "~@resources" ];
UMask = "0077";
};
};
services.nginx.virtualHosts."${secret.nginx.hostnames.libreddit}" = {
# listen = [
# {
# addr = "100.64.10.2";
# port = 443;
# ssl = true;
# extraParameters = [
# "fastopen=63"
# "backlog=1023"
# "deferred"
# ];
# }
#
# {
# addr = "[fd7a:115c:a1e0:1010::2]";
# port = 443;
# ssl = true;
# extraParameters = [
# "fastopen=63"
# "backlog=1023"
# ];
# }
# ];
listenAddresses = [ "100.64.10.2" "[fd7a:115c:a1e0:1010::2]" ];
quic = true;
http3 = true;
onlySSL = true;
useACMEHost = "daniel.sx";
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:8002";
};
};
}