dotfiles/system/nixos/adguardhome.nix

106 lines
2.1 KiB
Nix
Raw Normal View History

2023-06-07 18:40:27 +00:00
{ lib, config, secret, ... }:
2023-05-15 20:11:58 +00:00
{
services.adguardhome = {
enable = true;
settings = {
bind_host = "127.0.0.1";
bind_port = 3000;
2023-06-07 18:40:27 +00:00
users = [
{
inherit (secret.adguardhome.users.daniel) name password;
}
];
2023-05-15 20:11:58 +00:00
auth_attempts = 3;
debug_pprof = false;
dns = {
2023-07-16 22:17:50 +00:00
inherit (secret.adguardhome) bind_hosts;
2023-05-15 20:11:58 +00:00
port = 53;
bootstrap_dns = [
"9.9.9.11"
"149.112.112.11"
"2620:fe::11"
"2620:fe::fe:11"
];
};
tls = {
enabled = false;
allow_unencrypted_doh = true;
};
dhcp.enabled = false;
};
};
2023-06-07 18:40:27 +00:00
networking.firewall.interfaces =
let
2023-07-16 22:17:50 +00:00
interfaces = lib.mapAttrsToList (_: lib.attrsets.attrByPath [ "matchConfig" "Name" ] null) config.systemd.network.networks;
2023-06-07 18:40:27 +00:00
in
builtins.listToAttrs
(builtins.map
(iface:
{
name = iface;
value = {
allowedTCPPorts = [ 53 9053 ];
allowedUDPPorts = [ 53 9053 ];
};
})
(builtins.filter builtins.isString interfaces));
2023-06-10 18:48:07 +00:00
virtualisation.podman.defaultNetwork.settings.dns_enabled = lib.mkForce secret.adguardhome.podmanDNS;
services.nginx.virtualHosts."${secret.adguardhome.domain_prefix}.internal.kempkens.network" = {
2023-06-07 18:40:27 +00:00
serverAliases = [ "dns.internal.kempkens.network" ];
listen = [
{
addr = "0.0.0.0";
port = 443;
ssl = true;
}
{
addr = "[::0]";
port = 443;
ssl = true;
}
{
addr = "0.0.0.0";
port = 9053;
ssl = true;
}
{
addr = "[::0]";
port = 9053;
ssl = true;
}
];
2023-05-15 20:11:58 +00:00
quic = true;
http3 = true;
onlySSL = true;
useACMEHost = "internal.kempkens.network";
2023-06-07 18:40:27 +00:00
extraConfig = ''
set_real_ip_from 100.108.165.26/32;
set_real_ip_from fd7a:115c:a1e0:ab12:4843:cd96:626c:a51a/128;
2023-06-07 18:40:27 +00:00
real_ip_header X-Forwarded-For;
'';
2023-05-15 20:11:58 +00:00
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:3000";
};
};
}