diff --git a/infra/modules/email/zones.tf b/infra/modules/email/zones.tf index 7b70171..d2ef616 100644 --- a/infra/modules/email/zones.tf +++ b/infra/modules/email/zones.tf @@ -16,6 +16,50 @@ resource "ovh_domain_zone_record" "aaaa" { ttl = 300 } +resource "ovh_domain_zone_record" "autoconfig_a" { + for_each = toset(var.ipv4) + zone = var.zone + subdomain = "autoconfig" + fieldtype = "A" + target = each.value + ttl = 300 +} + +resource "ovh_domain_zone_record" "autoconfig_aaaa" { + for_each = toset(var.ipv6) + zone = var.zone + subdomain = "autoconfig" + fieldtype = "AAAA" + target = each.value + ttl = 300 +} + +resource "ovh_domain_zone_record" "autodiscover_a" { + for_each = toset(var.ipv4) + zone = var.zone + subdomain = "autodiscover" + fieldtype = "A" + target = each.value + ttl = 300 +} + +resource "ovh_domain_zone_record" "autodiscover_aaaa" { + for_each = toset(var.ipv6) + zone = var.zone + subdomain = "autodiscover" + fieldtype = "AAAA" + target = each.value + ttl = 300 +} + +resource "ovh_domain_zone_record" "autodiscover_srv" { + zone = var.zone + subdomain = "_autodiscover._tcp" + fieldtype = "SRV" + target = "0 0 443 autoconfig.${var.zone}." + ttl = 3600 +} + resource "ovh_domain_zone_record" "dkim" { zone = var.zone subdomain = "default._domainkey" diff --git a/modules/mail/default.nix b/modules/mail/default.nix index d0dae0f..ea7e693 100644 --- a/modules/mail/default.nix +++ b/modules/mail/default.nix @@ -23,6 +23,20 @@ in locations."/".proxyPass = "http://127.0.0.1:6801"; }; + services.nginx.virtualHosts."autoconfig.${domain}" = { + forceSSL = true; + enableACME = true; + + locations."/".proxyPass = "http://127.0.0.1:6801"; + }; + + services.nginx.virtualHosts."autodiscover.${domain}" = { + forceSSL = true; + enableACME = true; + + locations."/".proxyPass = "http://127.0.0.1:6801"; + }; + security.acme.certs.${mail-domain}.reloadServices = [ "stalwart" ]; @@ -92,7 +106,28 @@ in default = true; }; - storage.directory = "memory"; + storage = { + directory = "memory"; + + data = "sqlite"; + fts = "sqlite"; + blob = "sqlite"; + lookup = "sqlite"; + }; + + store.sqlite = { + type = "sqlite"; + path = "${config.services.stalwart.dataDir}/sqlite.db"; + + pool = { + max-connections = 10; + workers = 10; + }; + + purge.frequency = "0 3 *"; + }; + + directory.memory = { type = "memory";