From 72070ee7bd265ee68de1181cf1fd4928ee528230 Mon Sep 17 00:00:00 2001 From: David Duque Date: Mon, 20 Apr 2020 18:17:41 +0100 Subject: [PATCH] Create custom nginx files --- conf/nginx-custom.conf | 2 +- management/web_update.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/conf/nginx-custom.conf b/conf/nginx-custom.conf index c9403104..83737884 100644 --- a/conf/nginx-custom.conf +++ b/conf/nginx-custom.conf @@ -11,7 +11,7 @@ # we're blocking dotfiles in the static hosted sites but not the FastCGI- # handled locations for Nextcloud (which serves user-uploaded files that might # have this pattern, see #414) or some of the other services. - location ~ /\.(ht|svn|git|hg|bzr|*.conf) { + location ~ /\.(ht|svn|git|hg|bzr|.*\.conf) { log_not_found off; access_log off; deny all; diff --git a/management/web_update.py b/management/web_update.py index cb28836a..62be27fc 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -93,10 +93,20 @@ 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(env["STORAGE_ROOT"], "www", safe_domain_name(domain), ".nginx.conf") + if os.path.exists(nginx_conf_custom): + with open(nginx_conf_custom, "r") as f: + local_conf = f.read() + if domain not in has_root_proxy_or_redirect: - nginx_conf += make_domain_config(domain, [template0, template1], ssl_certificates, env) + local_conf = make_domain_config(domain, [template0, template1], ssl_certificates, env) else: - nginx_conf += make_domain_config(domain, [template0], ssl_certificates, env) + local_conf = make_domain_config(domain, [template0], ssl_certificates, env) + nginx_conf += local_conf + + with open(nginx_conf, "r+") as f: + f.write(local_conf) else: # Add default 'www.' redirect. nginx_conf += make_domain_config(domain, [template0, template4], ssl_certificates, env)