feat(server): setup beszel for monitoring vps's.
This commit is contained in:
parent
9a8286e43b
commit
9a5b0770e2
4 changed files with 100 additions and 0 deletions
51
modules/servers/general/beszel-agent.nix
Normal file
51
modules/servers/general/beszel-agent.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{pkgs, ...}: {
|
||||
systemd.services.beszel-agent = {
|
||||
enable = true;
|
||||
description = "Beszel Agent";
|
||||
after = ["network.target"];
|
||||
wants = ["network.target"];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
RestartSec = 3;
|
||||
User = "beszel";
|
||||
Group = "beszel";
|
||||
WorkingDirectory = "/var/lib/beszel";
|
||||
StateDirectory = "beszel-agent";
|
||||
|
||||
KeyringMode = "private";
|
||||
LockPersonality = "yes";
|
||||
NoNewPrivileges = "yes";
|
||||
ProtectClock = "yes";
|
||||
ProtectHome = "read-only";
|
||||
ProtectHostname = "yes";
|
||||
ProtectKernelLogs = "yes";
|
||||
ProtectSystem = "strict";
|
||||
RemoveIPC = "yes";
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
};
|
||||
|
||||
script = "${pkgs.beszel}/bin/beszel-agent -listen '45876' --key 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC+T3fFx+Sv8jBGr2gNUHfuwUCbGhj8Mr/h4pmkI2Zjn'";
|
||||
|
||||
wantedBy = ["multi-user.target"];
|
||||
};
|
||||
|
||||
users = {
|
||||
users.beszel = {
|
||||
isSystemUser = true;
|
||||
home = "/var/lib/beszel";
|
||||
createHome = true;
|
||||
group = "beszel";
|
||||
};
|
||||
groups.beszel = {};
|
||||
};
|
||||
|
||||
networking.firewall.extraCommands = ''
|
||||
iptables -N beszel # create a new chain named beszel
|
||||
iptables -A beszel --src 65.21.241.194 -j ACCEPT # allow 65.21.241.194
|
||||
iptables -A beszel -j DROP # drop everyone else
|
||||
iptables -I INPUT -m tcp -p tcp --dport 45876 -j beszel # use chain beszel for packets coming to TCP port 45876
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue