1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-12-25 07:47:05 +00:00

Do not apply custom nginx dotfiles to the default webroot

This commit is contained in:
David Duque 2020-04-24 17:03:13 +01:00
parent d9567c0035
commit 32e42f14fb
No known key found for this signature in database
GPG Key ID: 2F327738A3C0AE3A

View File

@ -102,7 +102,7 @@ def do_web_update(env):
# This is a regular domain. # This is a regular domain.
local_conf = "" local_conf = ""
nginx_conf_custom = os.path.join(get_web_root(domain, env), ".nginx.conf") nginx_conf_custom = os.path.join(get_web_root(domain, env), ".nginx.conf")
if os.path.exists(nginx_conf_custom): if os.path.exists(nginx_conf_custom) and not is_default_web_root(domain, env):
with open(nginx_conf_custom, "r") as f: with open(nginx_conf_custom, "r") as f:
local_conf = f.read() local_conf = f.read()
elif domain not in has_root_proxy_or_redirect: elif domain not in has_root_proxy_or_redirect:
@ -111,8 +111,9 @@ def do_web_update(env):
local_conf = make_domain_config(domain, [template0], ssl_certificates, env) local_conf = make_domain_config(domain, [template0], ssl_certificates, env)
nginx_conf += local_conf nginx_conf += local_conf
with open(nginx_conf_custom, "w+") as f: if not is_default_web_root(domain, env):
f.write(local_conf) with open(nginx_conf_custom, "w+") as f:
f.write(local_conf)
else: else:
# Add default 'www.' redirect. # Add default 'www.' redirect.
nginx_conf += make_domain_config(domain, [template0, template4], ssl_certificates, env) nginx_conf += make_domain_config(domain, [template0, template4], ssl_certificates, env)
@ -221,6 +222,10 @@ def get_web_root(domain, env, test_exists=True):
if os.path.exists(root) or not test_exists: break if os.path.exists(root) or not test_exists: break
return root return root
def is_default_web_root(domain, env):
root = os.path.join(env["STORAGE_ROOT"], "www", safe_domain_name(domain))
return not os.path.exists(root)
def get_web_domains_info(env): def get_web_domains_info(env):
www_redirects = set(get_web_domains(env)) - set(get_web_domains(env, include_www_redirects=False)) www_redirects = set(get_web_domains(env)) - set(get_web_domains(env, include_www_redirects=False))
has_root_proxy_or_redirect = set(get_web_domains_with_root_overrides(env)) has_root_proxy_or_redirect = set(get_web_domains_with_root_overrides(env))