feat(services): add adguardhome

This commit is contained in:
Felix Schröter 2025-05-10 16:58:42 +02:00
parent 43cb9890c9
commit 09554029fe
Signed by: felschr
GPG key ID: 671E39E6744C807D
3 changed files with 113 additions and 4 deletions
hosts/home-server
services
system

View file

@ -24,6 +24,7 @@ in
../../virtualisation/containers.nix
../../virtualisation/podman.nix
../../modules/inadyn.nix
../../services/adguardhome.nix
../../modules/systemdNotify.nix
../../services/postgres
../../services/mail.nix
@ -87,6 +88,7 @@ in
''}";
services.inadyn.domains = [
"felschr.com"
"dns.felschr.com"
"openpgpkey.felschr.com"
"ldap.felschr.com"
"auth.felschr.com"

107
services/adguardhome.nix Normal file
View file

@ -0,0 +1,107 @@
{ config, ... }:
let
cfg = config.services.adguardhome;
host = "dns.felschr.com";
in
{
services.adguardhome = {
enable = true;
settings = {
dns = {
upstream_dns = [
"https://dns.mullvad.net/dns-query"
];
fallback_dns = [
"https://1.1.1.1/dns-query"
];
enable_dnssec = true;
};
# encryption
tls = {
enabled = true;
server_name = host;
port_https = 0;
port_dns_over_tls = 853;
port_dns_over_quic = 853;
port_dnscrypt = 0;
force_https = false; # handled by nginx
allow_unencrypted_doh = true;
strict_sni_check = false;
certificate_path = "/run/credentials/adguardhome.service/fullchain.pem";
private_key_path = "/run/credentials/adguardhome.service/key.pem";
};
# HINT: users needs to be set up manually:
# https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration#password-reset
# users = [ { name = "felschr"; } ];
querylog = {
enabled = true;
interval = "24h";
};
statistics = {
enabled = true;
interval = "24h";
};
filtering = {
protection_enabled = true;
filtering_enabled = true;
safe_search.enabled = true;
rewrites = [
{
domain = "felschr.com";
answer = "home-server.tail05275.ts.net";
}
{
domain = "*.felschr.com";
answer = "home-server.tail05275.ts.net";
}
];
};
filters = [
{
name = "HaGeZi Multi Pro";
url = "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.txt";
enabled = true;
}
{
name = "OISD (Big)";
url = "https://big.oisd.nl";
enabled = false;
}
{
name = "AdGuard DNS filter";
url = "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt";
enabled = false;
}
];
whitelist_filters = [
{
name = "HaGeZi Whitelist-Referral";
url = "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/whitelist-referral.txt";
enabled = true;
}
{
name = "Hagezi Whitelist-UrlShortener";
url = "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/whitelist-urlshortener.txt";
enabled = true;
}
];
};
};
systemd.services.adguardhome.serviceConfig = {
LoadCredential = [
"fullchain.pem:/var/lib/acme/${host}/fullchain.pem"
"key.pem:/var/lib/acme/${host}/key.pem"
];
};
services.nginx.virtualHosts."${host}" = {
enableACME = true;
forceSSL = true;
locations."/".proxyPass = "http://localhost:${toString cfg.port}";
};
networking.firewall.allowedTCPPorts = [ 853 ];
networking.firewall.allowedUDPPorts = [ 853 ];
}

View file

@ -15,14 +15,14 @@
table inet allow-incoming-traffic {
chain allow-incoming {
type filter hook input priority -100; policy accept;
tcp dport {80, 443, 2222} meta mark set 0x80000;
udp dport {80, 443, 2222} meta mark set 0x80000;
tcp dport {80, 443, 853, 2222} meta mark set 0x80000;
udp dport {80, 443, 853, 2222} meta mark set 0x80000;
}
chain allow-outgoing {
type route hook output priority -100; policy accept;
tcp sport {80, 443, 2222} meta mark set 0x80000;
udp sport {80, 443, 2222} meta mark set 0x80000;
tcp sport {80, 443, 853, 2222} meta mark set 0x80000;
udp sport {80, 443, 853, 2222} meta mark set 0x80000;
}
}
'';