if the user has set a http proxy or redirect on the root path of a domain, using custom.yaml, skip the domain from the static hosting panel because it wont be serving any static files

This commit is contained in:
Joshua Tauberer 2015-02-05 08:55:57 -05:00
parent 21b00e8fbb
commit 97be9c94b9
2 changed files with 13 additions and 0 deletions

View file

@ -64,6 +64,7 @@ function show_web() {
var tb = $('#web_domains_existing tbody'); var tb = $('#web_domains_existing tbody');
tb.text(''); tb.text('');
for (var i = 0; i < domains.length; i++) { for (var i = 0; i < domains.length; i++) {
if (!domains[i].static_enabled) continue;
var row = $("<tr><th class='domain'><a href=''></a></th><td class='directory'><tt/></td></tr>"); var row = $("<tr><th class='domain'><a href=''></a></th><td class='directory'><tt/></td></tr>");
tb.append(row); tb.append(row);
row.find('.domain a').text('https://' + domains[i].domain); row.find('.domain a').text('https://' + domains[i].domain);
@ -74,6 +75,7 @@ function show_web() {
tb = $('#web_domains_custom tbody'); tb = $('#web_domains_custom tbody');
tb.text(''); tb.text('');
for (var i = 0; i < domains.length; i++) { for (var i = 0; i < domains.length; i++) {
if (!domains[i].static_enabled) continue;
if (domains[i].root != domains[i].custom_root) { if (domains[i].root != domains[i].custom_root) {
var row = $("<tr><th class='domain'><a href=''></a></th><td class='directory'><tt></td></tr>"); var row = $("<tr><th class='domain'><a href=''></a></th><td class='directory'><tt></td></tr>");
tb.append(row); tb.append(row);

View file

@ -250,6 +250,16 @@ def install_cert(domain, ssl_cert, ssl_chain, env):
return "\n".join(r for r in ret if r.strip() != "") return "\n".join(r for r in ret if r.strip() != "")
def get_web_domains_info(env): def get_web_domains_info(env):
# load custom settings so we can tell what domains have a redirect or proxy set up on '/',
# which means static hosting is not happening
custom_settings = { }
nginx_conf_custom_fn = os.path.join(env["STORAGE_ROOT"], "www/custom.yaml")
if os.path.exists(nginx_conf_custom_fn):
custom_settings = rtyaml.load(open(nginx_conf_custom_fn))
def has_root_proxy_or_redirect(domain):
return custom_settings.get(domain, {}).get('redirects', {}).get('/') or custom_settings.get(domain, {}).get('proxies', {}).get('/')
# for the SSL config panel, get cert status
def check_cert(domain): def check_cert(domain):
from status_checks import check_certificate from status_checks import check_certificate
ssl_key, ssl_certificate = get_domain_ssl_files(domain, env) ssl_key, ssl_certificate = get_domain_ssl_files(domain, env)
@ -273,6 +283,7 @@ def get_web_domains_info(env):
"root": get_web_root(domain, env), "root": get_web_root(domain, env),
"custom_root": get_web_root(domain, env, test_exists=False), "custom_root": get_web_root(domain, env, test_exists=False),
"ssl_certificate": check_cert(domain), "ssl_certificate": check_cert(domain),
"static_enabled": not has_root_proxy_or_redirect(domain),
} }
for domain in get_web_domains(env) for domain in get_web_domains(env)
] ]