From 32e42f14fb15c8b2c3e479f4b32d9760bd022cc7 Mon Sep 17 00:00:00 2001 From: David Duque Date: Fri, 24 Apr 2020 17:03:13 +0100 Subject: [PATCH] Do not apply custom nginx dotfiles to the default webroot --- management/web_update.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/management/web_update.py b/management/web_update.py index 964f279b..dad80850 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -102,7 +102,7 @@ def do_web_update(env): # This is a regular domain. local_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: local_conf = f.read() 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) nginx_conf += local_conf - with open(nginx_conf_custom, "w+") as f: - f.write(local_conf) + if not is_default_web_root(domain, env): + with open(nginx_conf_custom, "w+") as f: + f.write(local_conf) else: # Add default 'www.' redirect. 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 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): 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))