From 9bfff1f6796c2fc180d2a91fd0d0b48499d98bec Mon Sep 17 00:00:00 2001 From: Sebastian Kosch Date: Sun, 24 Aug 2014 17:34:15 -0400 Subject: [PATCH 1/3] Add server block customizations This allows users to add a file /etc/nginx/conf.d/includes/mydomain.com.conf, the contents of which will be included in the server block for mydomain.com. --- management/web_update.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/management/web_update.py b/management/web_update.py index 5131d9c9..2514bc22 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -94,7 +94,7 @@ def make_domain_config(domain, template, template_for_primaryhost, env): nginx_conf = nginx_conf.replace("$SSL_KEY", ssl_key) nginx_conf = nginx_conf.replace("$SSL_CERTIFICATE", ssl_certificate) - # Add in any user customizations. + # Add in any user customizations in YAML format. nginx_conf_custom_fn = os.path.join(env["STORAGE_ROOT"], "www/custom.yaml") if os.path.exists(nginx_conf_custom_fn): yaml = rtyaml.load(open(nginx_conf_custom_fn)) @@ -103,6 +103,11 @@ def make_domain_config(domain, template, template_for_primaryhost, env): for path, url in yaml.get("proxies", {}).items(): nginx_conf += "\tlocation %s {\n\t\tproxy_pass %s;\n\t}\n" % (path, url) + # Add in any user customizations in the includes/ folder. + nginx_conf_custom_include = os.path.join("/etc/nginx/conf.d/includes/", domain + ".conf") + if os.path.exists(nginx_conf_custom_include): + nginx_conf += "\tinclude %s;\n" % (nginx_conf_custom_include) + # Ending. nginx_conf += nginx_conf_parts[1] From 76ff9735cc28f520a9015f675e8870c0df43a3f8 Mon Sep 17 00:00:00 2001 From: Sebastian Kosch Date: Mon, 25 Aug 2014 13:25:44 -0400 Subject: [PATCH 2/3] Move custom server blocks to STORAGE_ROOT --- management/web_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/management/web_update.py b/management/web_update.py index 2514bc22..b5528553 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -104,7 +104,7 @@ def make_domain_config(domain, template, template_for_primaryhost, env): nginx_conf += "\tlocation %s {\n\t\tproxy_pass %s;\n\t}\n" % (path, url) # Add in any user customizations in the includes/ folder. - nginx_conf_custom_include = os.path.join("/etc/nginx/conf.d/includes/", domain + ".conf") + nginx_conf_custom_include = os.path.join(env["STORAGE_ROOT"], "www", safe_domain_name(test_domain) + ".conf") if os.path.exists(nginx_conf_custom_include): nginx_conf += "\tinclude %s;\n" % (nginx_conf_custom_include) From 00b5c6ee9ca7128e28485dcfe7afd0510e4b309d Mon Sep 17 00:00:00 2001 From: Sebastian Kosch Date: Mon, 25 Aug 2014 16:02:13 -0400 Subject: [PATCH 3/3] test_domain -> domain --- management/web_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/management/web_update.py b/management/web_update.py index b5528553..274c33d9 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -104,7 +104,7 @@ def make_domain_config(domain, template, template_for_primaryhost, env): nginx_conf += "\tlocation %s {\n\t\tproxy_pass %s;\n\t}\n" % (path, url) # Add in any user customizations in the includes/ folder. - nginx_conf_custom_include = os.path.join(env["STORAGE_ROOT"], "www", safe_domain_name(test_domain) + ".conf") + nginx_conf_custom_include = os.path.join(env["STORAGE_ROOT"], "www", safe_domain_name(domain) + ".conf") if os.path.exists(nginx_conf_custom_include): nginx_conf += "\tinclude %s;\n" % (nginx_conf_custom_include)