1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-16 17:47:23 +01:00

Revert .nginx.conf file features

This commit is contained in:
David Duque
2020-09-27 01:31:51 +01:00
parent 689df9cff5
commit 7725e6efe6
3 changed files with 8 additions and 62 deletions

View File

@@ -80,20 +80,12 @@ def do_web_update(env):
# Load the templates.
template0 = open(os.path.join(os.path.dirname(__file__), "../conf/nginx.conf")).read()
template1 = open(os.path.join(os.path.dirname(__file__), "../conf/nginx-default.conf")).read()
template1 = open(os.path.join(os.path.dirname(__file__), "../conf/nginx-alldomains.conf")).read()
template2 = open(os.path.join(os.path.dirname(__file__), "../conf/nginx-primaryonly.conf")).read()
template3 = open(os.path.join(os.path.dirname(__file__), "../conf/nginx-custom.conf")).read()
template4 = "\trewrite ^(.*) https://$REDIRECT_DOMAIN$1 permanent;\n"
template3 = "\trewrite ^(.*) https://$REDIRECT_DOMAIN$1 permanent;\n"
# Add the PRIMARY_HOST configuration first so it becomes nginx's default server.
default_conf = make_domain_config(env['PRIMARY_HOSTNAME'], [template0, template1, template2], ssl_certificates, env)
default_conf_file = os.path.join(get_web_root(env['PRIMARY_HOSTNAME'], env), ".nginx.conf")
if not os.path.exists(default_conf_file):
with open(default_conf_file, "w") as f:
f.write(default_conf)
nginx_conf += default_conf
nginx_conf += make_domain_config(env['PRIMARY_HOSTNAME'], [template0, template1, template2], ssl_certificates, env)
# Add configuration all other web domains.
has_root_proxy_or_redirect = get_web_domains_with_root_overrides(env)
@@ -104,23 +96,13 @@ def do_web_update(env):
continue
if domain in web_domains_not_redirect:
# 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) 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:
local_conf = make_domain_config(domain, [template0, template3], ssl_certificates, env)
if domain not in has_root_proxy_or_redirect:
nginx_conf += make_domain_config(domain, [template0, template1], ssl_certificates, env)
else:
local_conf = make_domain_config(domain, [template0], ssl_certificates, env)
nginx_conf += local_conf
if not is_default_web_root(domain, env):
with open(nginx_conf_custom, "w+") as f:
f.write(local_conf)
nginx_conf += make_domain_config(domain, [template0], ssl_certificates, env)
else:
# Add default 'www.' redirect.
nginx_conf += make_domain_config(domain, [template0, template4], ssl_certificates, env)
nginx_conf += make_domain_config(domain, [template0, template3], ssl_certificates, env)
# Did the file change? If not, don't bother writing & restarting nginx.
nginx_conf_fn = "/etc/nginx/conf.d/local.conf"