Compare commits
3 Commits
feature/se
...
8bdd0e352a
| Author | SHA1 | Date | |
|---|---|---|---|
| 8bdd0e352a | |||
| 9291d83870 | |||
| 6999d50f35 |
@@ -5,7 +5,6 @@ This document outlines the development conventions for this NixOS-based infrastr
|
|||||||
## Build & Deployment
|
## Build & Deployment
|
||||||
|
|
||||||
- **Build/Deploy:** Use `nixos-rebuild switch --flake .#<hostname>` to build and deploy the configuration for a specific host.
|
- **Build/Deploy:** Use `nixos-rebuild switch --flake .#<hostname>` to build and deploy the configuration for a specific host.
|
||||||
- **CRITICAL — Validate before pushing:** Always `nix build --no-link '.#nixosConfigurations.<hostname>.config.system.build.toplevel'` (or `nh os build`) and confirm it succeeds before pushing any changes. Never push untested NixOS configs.
|
|
||||||
- **Development Shell:** Activate the development environment with `nix develop`.
|
- **Development Shell:** Activate the development environment with `nix develop`.
|
||||||
|
|
||||||
## Linting & Formatting
|
## Linting & Formatting
|
||||||
|
|||||||
Submodule assets/compose updated: a79fe9dffa...fb0f2cbe84
@@ -314,7 +314,6 @@
|
|||||||
|
|
||||||
# Firewall - default deny, explicit allow
|
# Firewall - default deny, explicit allow
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
# Enable firewall with default deny policy (NixOS firewall denies all by default)
|
|
||||||
enable = true;
|
enable = true;
|
||||||
allowPing = true;
|
allowPing = true;
|
||||||
|
|
||||||
@@ -361,22 +360,11 @@
|
|||||||
banaction = "iptables-multiport";
|
banaction = "iptables-multiport";
|
||||||
|
|
||||||
jails = {
|
jails = {
|
||||||
# SSH brute force protection (uses systemd journal backend)
|
# Ban repeat offenders for 1 week
|
||||||
sshd = {
|
|
||||||
enabled = true;
|
|
||||||
settings = {
|
|
||||||
filter = "sshd";
|
|
||||||
port = "2424";
|
|
||||||
maxretry = 3;
|
|
||||||
bantime = "1h";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Recidive - ban repeat offenders for 1 week
|
|
||||||
recidive = {
|
recidive = {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
filter = "recidive";
|
||||||
settings = {
|
settings = {
|
||||||
filter = "recidive";
|
|
||||||
logpath = "/var/log/fail2ban.log";
|
logpath = "/var/log/fail2ban.log";
|
||||||
bantime = "1w";
|
bantime = "1w";
|
||||||
findtime = "1d";
|
findtime = "1d";
|
||||||
@@ -384,11 +372,21 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# HTTP authentication failures (Traefik)
|
# SSH brute force protection
|
||||||
http-auth = {
|
sshd = {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
settings = {
|
settings = {
|
||||||
filter = "traefik-auth";
|
port = "2424";
|
||||||
|
maxretry = 3;
|
||||||
|
bantime = "1h";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# HTTP authentication failures
|
||||||
|
http-auth = {
|
||||||
|
enabled = true;
|
||||||
|
filter = "apache-auth";
|
||||||
|
settings = {
|
||||||
port = "80,443";
|
port = "80,443";
|
||||||
logpath = "/var/log/traefik/access.log";
|
logpath = "/var/log/traefik/access.log";
|
||||||
maxretry = 5;
|
maxretry = 5;
|
||||||
@@ -396,11 +394,11 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# HTTP scanning/attacks (Traefik)
|
# HTTP scanning/attacks
|
||||||
http-botsearch = {
|
http-botsearch = {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
filter = "apache-botsearch";
|
||||||
settings = {
|
settings = {
|
||||||
filter = "traefik-botsearch";
|
|
||||||
port = "80,443";
|
port = "80,443";
|
||||||
logpath = "/var/log/traefik/access.log";
|
logpath = "/var/log/traefik/access.log";
|
||||||
maxretry = 2;
|
maxretry = 2;
|
||||||
@@ -409,20 +407,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Custom fail2ban filters for Traefik
|
|
||||||
environment.etc."fail2ban/filter.d/traefik-auth.conf".text = ''
|
|
||||||
[Definition]
|
|
||||||
failregex = ^<HOST> -.*"(GET|POST|HEAD|PUT|DELETE).*" (401|403) \d+.*$
|
|
||||||
ignoreregex =
|
|
||||||
'';
|
|
||||||
|
|
||||||
environment.etc."fail2ban/filter.d/traefik-botsearch.conf".text = ''
|
|
||||||
[Definition]
|
|
||||||
failregex = ^<HOST> -.*"(GET|POST|HEAD|PUT|DELETE).*" 404 \d+.*$
|
|
||||||
^<HOST> -.*"(GET|POST|HEAD|PUT|DELETE).*/(\.|wp-|php|admin|login|xmlrpc|\.env|\.git|\.aws|\.azure).*" \d+.*$
|
|
||||||
ignoreregex =
|
|
||||||
'';
|
|
||||||
|
|
||||||
# SSH hardening
|
# SSH hardening
|
||||||
services.openssh.settings = {
|
services.openssh.settings = {
|
||||||
@@ -490,7 +474,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Audit logging
|
# Audit logging
|
||||||
security.auditd.enable = true;
|
security.audit.enable = true;
|
||||||
|
|
||||||
# Fail2ban log directory
|
# Fail2ban log directory
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
|
|||||||
Reference in New Issue
Block a user