diff --git a/management/daemon.py b/management/daemon.py
index d450c63..47287ce 100755
--- a/management/daemon.py
+++ b/management/daemon.py
@@ -74,6 +74,7 @@ def index():
no_admins_exist = (len([user for user in get_mail_users(env, as_json=True) if "admin" in user['privileges']]) == 0)
return render_template('index.html',
hostname=env['PRIMARY_HOSTNAME'],
+ storage_root=env['STORAGE_ROOT'],
no_admins_exist=no_admins_exist,
)
@@ -227,6 +228,12 @@ def dns_get_dump():
# WEB
+@app.route('/web/domains')
+@authorized_personnel_only
+def web_get_domains():
+ from web_update import get_web_domains_info
+ return json_response(get_web_domains_info(env))
+
@app.route('/web/update', methods=['POST'])
@authorized_personnel_only
def web_update():
diff --git a/management/templates/index.html b/management/templates/index.html
index efe80bb..31063e2 100644
--- a/management/templates/index.html
+++ b/management/templates/index.html
@@ -60,6 +60,10 @@
table.table {
margin: 1.5em 0;
}
+
+ ol li {
+ margin-bottom: 1em;
+ }
+
+
Static Web Hosting
+
+
This machine is serving a simple, static website at https://{{hostname}} and at all domain names that you set up an email user or alias for.
+
+
Uploading web files
+
+
You can replace this website with your own HTML or other static files:
+
+
+
Ensure that the domains and SSL certificates are configured properly on the Status Checks page.
+
+
Install an SSH file transfer program such as FileZilla or scp.
+
+
Log in with the file transfer program. The server is {{hostname}}, the protocol is SSH or SFTP, and use the SSH login credentials that you used when you originally created this machine at your cloud host provider. This is not what you use to log in either for email or this control panel. Your SSH credentials probably involves a private key file.
+
+
Replace the files in {{storage_root}}/www/default, or the directory indicated in the table below, with any HTML pages or other static files. They will appear directly and immediately on the web.
+
+
+
+
+
Site
+
Directory for Files
+
+
+
+
+
+
+
If you want to have this box host a static website on a domain that is not listed in the table, create a dummy mail user or alias on the domain first.
+
+
+
+
Different sites for different domains
+
+
Create one of the directories shown in the table below to create a space for different files for one of the websites.
+
+
After you create one of these directories, click to restart the box’s web server so that it sees the new website file location.
+
+
+
+
+
Site
+
Create Directory
+
+
+
+
+
+
+
+
diff --git a/management/web_update.py b/management/web_update.py
index 9198232..edf5ab2 100644
--- a/management/web_update.py
+++ b/management/web_update.py
@@ -113,11 +113,11 @@ def make_domain_config(domain, template, template_for_primaryhost, env):
return nginx_conf
-def get_web_root(domain, env):
+def get_web_root(domain, env, test_exists=True):
# Try STORAGE_ROOT/web/domain_name if it exists, but fall back to STORAGE_ROOT/web/default.
for test_domain in (domain, 'default'):
root = os.path.join(env["STORAGE_ROOT"], "www", safe_domain_name(test_domain))
- if os.path.exists(root): break
+ if os.path.exists(root) or not test_exists: break
return root
def get_domain_ssl_files(domain, env):
@@ -193,3 +193,12 @@ def ensure_ssl_certificate_exists(domain, ssl_key, ssl_certificate, csr_path, en
"-signkey", ssl_key,
"-out", ssl_certificate])
+def get_web_domains_info(env):
+ return [
+ {
+ "domain": domain,
+ "root": get_web_root(domain, env),
+ "custom_root": get_web_root(domain, env, test_exists=False),
+ }
+ for domain in get_web_domains(env)
+ ]