mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-26 02:57:04 +00:00
if a user sets a custom A record on PRIMARY_HOSTNAME, which is ignored anyway, don't let that cause PRIMARY_HOSTNAME from being dropped from nginx.conf
Could be related to https://discourse.mailinabox.email/t/nginx-lost-admin-record-after-install-ssl-cert-problem/528.
This commit is contained in:
parent
e4caed9277
commit
c9add7a8bf
@ -19,15 +19,9 @@ def get_web_domains(env):
|
|||||||
# Also serve web for all mail domains so that we might at least
|
# Also serve web for all mail domains so that we might at least
|
||||||
# provide auto-discover of email settings, and also a static website
|
# provide auto-discover of email settings, and also a static website
|
||||||
# if the user wants to make one. These will require an SSL cert.
|
# if the user wants to make one. These will require an SSL cert.
|
||||||
domains |= get_mail_domains(env)
|
|
||||||
|
|
||||||
# ...Unless the domain has an A/AAAA record that maps it to a different
|
# ...Unless the domain has an A/AAAA record that maps it to a different
|
||||||
# IP address than this box. Remove those domains from our list.
|
# IP address than this box. Remove those domains from our list.
|
||||||
dns = get_custom_dns_config(env)
|
domains |= (get_mail_domains(env) - get_domains_with_a_records(env))
|
||||||
for domain, rtype, value in dns:
|
|
||||||
if domain not in domains: continue
|
|
||||||
if rtype == "CNAME" or (rtype in ("A", "AAAA") and value != "local"):
|
|
||||||
domains.remove(domain)
|
|
||||||
|
|
||||||
# Sort the list. Put PRIMARY_HOSTNAME first so it becomes the
|
# Sort the list. Put PRIMARY_HOSTNAME first so it becomes the
|
||||||
# default server (nginx's default_server).
|
# default server (nginx's default_server).
|
||||||
@ -35,6 +29,14 @@ def get_web_domains(env):
|
|||||||
|
|
||||||
return domains
|
return domains
|
||||||
|
|
||||||
|
def get_domains_with_a_records(env):
|
||||||
|
domains = set()
|
||||||
|
dns = get_custom_dns_config(env)
|
||||||
|
for domain, rtype, value in dns:
|
||||||
|
if rtype == "CNAME" or (rtype in ("A", "AAAA") and value != "local"):
|
||||||
|
domains.add(domain)
|
||||||
|
return domains
|
||||||
|
|
||||||
def do_web_update(env):
|
def do_web_update(env):
|
||||||
# Build an nginx configuration file.
|
# Build an nginx configuration file.
|
||||||
nginx_conf = open(os.path.join(os.path.dirname(__file__), "../conf/nginx-top.conf")).read()
|
nginx_conf = open(os.path.join(os.path.dirname(__file__), "../conf/nginx-top.conf")).read()
|
||||||
|
Loading…
Reference in New Issue
Block a user