refactor: simplify DNS configuration for vhosts with dynamic interface detection
This commit is contained in:
parent
301629243e
commit
1a54c00cc2
@ -13,8 +13,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Configure AdGuard
|
# Configure AdGuard
|
||||||
pepe.core.vhost.hosts."adguard.giugl.io" = with config.pepe.core.network; {
|
pepe.core.vhost.hosts."adguard.giugl.io" = {
|
||||||
dnsInterfaces = [ interfacesByType.vpn interfacesByType.lan ];
|
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
port = config.services.adguardhome.port;
|
port = config.services.adguardhome.port;
|
||||||
allowLAN = true;
|
allowLAN = true;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types mapAttrs concatMapStringsSep optionalString;
|
inherit (lib) mkOption types mapAttrs concatMapStringsSep optionalString mkIf;
|
||||||
cfg = config.pepe.core.vhost;
|
cfg = config.pepe.core.vhost;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@ -9,13 +9,6 @@ in
|
|||||||
hosts = mkOption {
|
hosts = mkOption {
|
||||||
type = types.attrsOf (types.submodule {
|
type = types.attrsOf (types.submodule {
|
||||||
options = {
|
options = {
|
||||||
dnsInterfaces = mkOption {
|
|
||||||
type = types.listOf types.str;
|
|
||||||
default = [ ];
|
|
||||||
description = "List of interfaces to add extra DNS hosts for this vhost.";
|
|
||||||
example = "config.pepe.core.network.interfaceTypes.lan";
|
|
||||||
};
|
|
||||||
|
|
||||||
locations = mkOption {
|
locations = mkOption {
|
||||||
type = types.attrsOf (types.submodule {
|
type = types.attrsOf (types.submodule {
|
||||||
options = {
|
options = {
|
||||||
@ -88,6 +81,17 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
# Configure DNS entries for vhosts when DNS is enabled
|
||||||
|
pepe.core.dns = mkIf config.pepe.core.dns.enable {
|
||||||
|
extraDomains = mapAttrs (domain: conf: {
|
||||||
|
dnsInterfaces =
|
||||||
|
(lib.optionals (lib.any (loc: loc.allowLAN) (lib.attrValues conf.locations))
|
||||||
|
config.pepe.core.network.interfacesByType.lan) ++
|
||||||
|
(lib.optionals (lib.any (loc: loc.allowVPN) (lib.attrValues conf.locations))
|
||||||
|
config.pepe.core.network.interfacesByType.vpn);
|
||||||
|
}) cfg.hosts;
|
||||||
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts = mapAttrs
|
services.nginx.virtualHosts = mapAttrs
|
||||||
(domain: conf: {
|
(domain: conf: {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user