Create custom nginx files

This commit is contained in:
David Duque 2020-04-20 18:17:41 +01:00
parent 830248bf66
commit 72070ee7bd
No known key found for this signature in database
GPG key ID: 2F327738A3C0AE3A
2 changed files with 13 additions and 3 deletions

View file

@ -11,7 +11,7 @@
# we're blocking dotfiles in the static hosted sites but not the FastCGI- # we're blocking dotfiles in the static hosted sites but not the FastCGI-
# handled locations for Nextcloud (which serves user-uploaded files that might # handled locations for Nextcloud (which serves user-uploaded files that might
# have this pattern, see #414) or some of the other services. # 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; log_not_found off;
access_log off; access_log off;
deny all; deny all;

View file

@ -93,10 +93,20 @@ def do_web_update(env):
continue continue
if domain in web_domains_not_redirect: if domain in web_domains_not_redirect:
# This is a regular domain. # 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: 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: 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: 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)