Document and test public hosting deployments

This commit is contained in:
parkel committed 2026-11-22 17:51:05 +01:00
1 parent 9e66510f7c
commit 4a955c7095
3 files changed
+317 -15

No files matched your search

+127 -15
View File
@@ -23,9 +23,12 @@ Ubuntu 26.04 LTS is the primary target. The installer also accepts Debian
PHP-FPM on Ubuntu 26.04 and Debian 13. Manage upgrades through the
[upgrade guide](#upgrade-an-existing-panel).
Choose HTTPS at Apache or a trusted external HTTPS proxy. For HTTPS at
Apache, provide an existing certificate chain and private key for the
panel hostname. Keep the TLS files in a system location such as
Choose Let's Encrypt, an existing TLS certificate, or a trusted external
HTTPS proxy. For Let's Encrypt, set `access = "acme"` and point the panel
hostname's public A and AAAA records at the host accepting HTTP on port 80.
Certbot requests and renews the certificate using HTTP-01. The operator
email is used for the ACME account. See Certbot's log if a challenge fails.
For an existing certificate, keep the TLS files in a system location such as
`/etc/ssl/` or `/etc/letsencrypt/`. This also works on a LAN with an
internal CA. For an
external proxy, provide the private origin address and port and the
@@ -36,10 +39,12 @@ The installer generates the panel, MariaDB, and RabbitMQ secrets. It
binds MariaDB and the broker's AMQP listener to loopback and configures
Apache, the panel, the workers, and the scheduler. Keep service management
ports private. A local DNS selection configures authoritative BIND9.
A local mail selection needs a certificate and private key for its own
hostname and configures Postfix delivery and Dovecot IMAP. Use the
additional deployment sections for services such as customer submission,
webmail, Certbot automation, and account backups.
A managed mail installation configures Postfix delivery and authenticated
SMTP submission, Dovecot IMAP, and Rspamd signing and rate limits. Provide
a certificate and private key for the mail hostname or choose `tls = "acme"`.
For ACME on a separate mail node, port 80 must be free for the Certbot
standalone listener during issuance and renewal. Use the additional
deployment sections for webmail, hosted website HTTPS, and account backups.
### Interactive command line
@@ -87,14 +92,23 @@ the first administrator sign-in.
### Separate DNS and mail nodes
Select `remote` for either role. The installer uses the existing
[node installer and SSH enrolment](#install-and-enrol-a-node).
Prepare the receiver on the destination and obtain its verified SSH host
public key. Supply its hostname or IP, SSH port, and host key file to the
panel installer.
Choose `remote-install` to install and enrol a role on an existing server.
Both roles can use one destination or can be installed on separate servers.
Supply the destination hostname or IP, SSH port, its verified SSH host
public key file, an administrator username, and the path to a root-owned
`0600` private key on the installer host. The account must be able to run
the setup through noninteractive `sudo`. During setup, use a dedicated
administrative key which can be revoked when enrolment is complete.
For mail, set `mail_hostname` to the public service hostname. When using
provided TLS, `certificate` and `key` are paths on the mail node.
The panel installer generates a role key before checking the connection.
If the receiver has not authorized it yet, authorize the public key from
Choose `remote` to connect a receiver prepared with the existing
[node installer and SSH enrolment](#install-and-enrol-a-node). Supply its
verified SSH host key file and connection details.
The panel installer generates a restricted role key. `remote-install`
authorizes the key during setup. For an existing receiver in `remote` mode,
authorize the public key if it has yet to be added. Use the key from
`/etc/coulobre-remote/dns/id_ed25519.pub` or
`/etc/coulobre-remote/mail/id_ed25519.pub` using
`coulobre-node-setup authorize-panel` on the receiver. Run the panel
@@ -107,6 +121,10 @@ The installer preserves a configured panel and uses private state while
resuming. Review the [installation checks](#verify-a-new-installation)
before opening the panel to customers.
When two panels share a node, keep separate role keys and give each hosted
domain one panel owner. Review the installed receiver configuration before
adding an independent role to an existing server.
## Install the package and configure local services
Run these commands from a Coulobre checkout or an unpacked source release
@@ -1823,7 +1841,7 @@ for worker in normal controller; do
done
sudo install -m 0644 deploy/rspamd/settings.conf.example \
/etc/rspamd/local.d/settings.conf
sudo rspamadm configtest
sudo `rspamadm configtest`
sudo systemctl enable rspamd.service
sudo systemctl restart rspamd.service
```
@@ -2458,3 +2476,97 @@ sudo systemctl reload-or-restart ssh.service
Restart the panel after adding node IDs. Run the collector and open **Service
health** to check the remote readings. Recovery of the SSH connection or the
service is reflected by the next successful check.
## Operate public mail services
A managed mail installation enables authenticated SMTP on TCP 587 with
STARTTLS. Use the full mailbox address for logins. Rspamd signs the submitted
message and limits senders with the local Redis cache. The default policy
has a burst of 30 and refills at 120 per hour. Adjust the authenticated-user
bucket in `/etc/rspamd/local.d/ratelimit.conf` and run `rspamadm configtest`
before reloading Rspamd. Follow the [mail DNS steps](#check-and-provision-mail-dns)
to verify SPF, DKIM, and DMARC from an external recipient.
Operators with access to the hosting account and mail domain can open
**Mail queue** to collect a read-only Postfix summary for that domain.
Counts include entries whose envelope sender or recipient belongs to the
selected domain. Partially scanned queues are marked in the panel.
On a manually configured mail host, provision the TLS submission service
using the [existing Dovecot and Rspamd examples](#set-up-signing-on-a-coulobre-mail-node).
Enable `COULOBRE_MAIL_NODE_DKIM=1` on the panel to provision signing keys
with new mailbox requests. Enable automatic managed mail DNS separately
with public MX and sending addresses for the deployment.
## View hosted website usage
Open **Usage and logs** from a hosting account and choose **Collect current
usage**. Reload the page after the web and mail workers return their results.
The panel shows website storage, mailbox storage and limits, and the most
recent Apache access and error entries for each managed website.
HTTP totals measure response body bytes in the current UTC calendar month.
Totals start when Coulobre logging is enabled and reflect retained logs.
Coulobre marks results partial when a bounded scan cannot read all retained
entries. The account total includes its active independent sites.
Fresh web installations enable the usage receiver and rotate the logs
daily. On a web server upgraded from an earlier release, install the
receiver, its worker configuration, and the log rotation rules before
enabling the view.
```sh
sudo groupadd --system --force coulobre-usage-requests
sudo install -d -m 0755 /etc/systemd/system/coulobre-provisioner.service.d
sudo install -m 0644 deploy/systemd/coulobre-provisioner.service.d/website-usage.conf \
/etc/systemd/system/coulobre-provisioner.service.d/
sudo install -m 0644 deploy/systemd/coulobre-website-usage.socket \
deploy/systemd/coulobre-website-usage@.service /etc/systemd/system/
sudo install -m 0644 deploy/logrotate/coulobre-websites /etc/logrotate.d/
sudo install -m 0644 deploy/apache/coulobre-website-usage.conf \
/etc/apache2/conf-available/
sudo a2enconf coulobre-website-usage
sudo /opt/coulobre/bin/coulobre-website-usage enable-existing
sudo apache2ctl configtest
sudo systemctl reload apache2
sudo systemctl daemon-reload
sudo systemctl enable --now coulobre-website-usage.socket
```
Set `COULOBRE_WEBSITE_USAGE=1` in /etc/coulobre/panel.env, then restart
coulobre-panel and coulobre-provisioner. Grant operators who troubleshoot
websites the **Can view website usage** permission. Customers and resellers
can see usage for their assigned accounts.
## Set up a managed secondary DNS server
Use a dedicated primary BIND9 configuration managed by Coulobre and a second
host for the secondary. The primary may be on the panel or an external
Coulobre DNS node. Both hosts must run the same Coulobre release. Allow
TCP and UDP port 53 for public authoritative DNS, including zone transfers
from the secondary to the primary.
On the primary, generate a TSIG key called coulobre-transfer
with `tsig-keygen -a hmac-sha256 coulobre-transfer`. Save it at
`/etc/bind/coulobre-transfer.key` with owner root, group bind and mode 0640.
Copy the file using a trusted administrative connection to the same path
on the secondary, with the same owner, group and mode. Install BIND9 and
the receiver on the secondary using sudo ./deploy/install-node.sh dns
as needed. Then configure the pair using the other node's transfer IP
on each command.
```sh
# On the primary
sudo ./deploy/setup-secondary-dns.sh primary 192.0.2.53
# On the secondary
sudo ./deploy/setup-secondary-dns.sh secondary 192.0.2.52
```
The primary seeds a BIND catalog from its managed zones. Publication and
retirement update the catalog. The secondary uses authenticated BIND
transfers and persists its copy of each zone. Add both nameservers to
zone delegation and verify replies directly on both hosts.
On the panel, set `COULOBRE_DNS_REPLICATION_ADDRESSES` with the primary
then the secondary query IP, separated by a comma. Restart the panel
and select **Check replication** from a DNS zone to compare live
authoritative SOA serials.
@@ -0,0 +1,153 @@
import gzip
import json
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import patch
from django.contrib.auth import get_user_model
from django.test import SimpleTestCase, TestCase, override_settings
from django.urls import reverse
from coulobre.dns_catalog import render_catalog
from coulobre.mail_node import MailboxSpec, MailboxUsageRequest
from coulobre.mail_queue import QUEUE_NAMES, summarize_queue
from coulobre.web_node import WebSite
from coulobre.web_node_usage import read_site_log, without_usage_logs
from .models import Customer, HostingAccount, HostingMailDomain
class ServiceInspectionTests(SimpleTestCase):
def test_postfix_queue_counts_only_envelopes_for_requested_domain(self):
def entry(queue, sender, *recipients):
return json.dumps(
{
"queue_name": queue,
"sender": sender,
"recipients": [{"address": item} for item in recipients],
}
)
data = [
entry("deferred", "member@example.com", "other@elsewhere.test"),
entry("active", "sender@elsewhere.test", "member@example.com"),
entry("hold", "sender@notexample.com", "other@elsewhere.test"),
entry("incoming", "", "other@example.com", "more@example.com"),
]
recap = summarize_queue(data, "example.com")
self.assertEqual(
recap,
{
"partial": False,
"counts": dict(zip(QUEUE_NAMES, (1, 1, 0, 1, 0), strict=True)),
},
)
def test_rotated_access_logs_include_only_current_month(self):
with TemporaryDirectory() as directory:
logs = Path(directory)
active = logs / "coulobre-9.access"
active.write_bytes(b"20 4 200 GET /now\n")
active.with_suffix(".access.1").write_bytes(
b"19 5 200 GET /recent\n"
)
with gzip.open(active.with_suffix(".access.2.gz"), "wb") as old:
old.write(b"7 50 200 GET /old\n14 12 200 GET /earlier\n")
def open_test_log(path):
return path.open("rb"), path.name
with (
patch("coulobre.web_node_usage.LOG_DIRECTORY", logs),
patch("coulobre.web_node_usage.open_log", open_test_log),
):
usage, recent, partial = read_site_log(
"coulobre-9",
kind="access",
cutoff=10,
)
self.assertEqual(usage, 21)
self.assertEqual(recent[0], "20 4 200 GET /now")
self.assertFalse(partial)
def test_vhosts_use_the_site_identity_for_log_paths(self):
site = WebSite(2, "example.com", site_id=8)
config = site.render("apache", server_name="alias.example.com")
self.assertIn(
'CustomLog "/var/log/apache2/coulobre-s8.access"', config
)
self.assertNotIn("CustomLog", without_usage_logs(config))
self.assertIn(
"ServerName alias.example.com", without_usage_logs(config)
)
def test_catalog_has_stable_member_labels(self):
old = render_catalog(1, {"example.com", "other.example"})
new = render_catalog(2, {"example.com"})
member = next(
line
for line in old.splitlines()
if line.endswith("PTR example.com.")
)
self.assertIn(member, new.splitlines())
self.assertIn('version IN TXT "2"', new)
self.assertNotIn("PTR other.example.", new)
def test_mailbox_usage_request_requires_a_single_valid_mailbox(self):
mailbox = MailboxSpec("example.com", "one", 5)
from coulobre.mail_node import parse_mailbox_request
request = MailboxUsageRequest(mailbox)
self.assertEqual(parse_mailbox_request(request.manifest()), request)
broken = request.manifest()
broken["mailbox"]["local_part"] = "*"
with self.assertRaises(ValueError):
parse_mailbox_request(broken)
@override_settings(
WEBSITE_USAGE=True,
LOCAL_MAILBOX_PROVISIONING=True,
REQUIRE_PRIVILEGED_MFA=False,
)
class PublicOperationsAccessTests(TestCase):
def setUp(self):
users = get_user_model().objects
self.operator = users.create_superuser(
"operator", "ops@example.com", "fixture"
)
self.customer = users.create_user("customer", password="fixture")
self.other = users.create_user("other", password="fixture")
self.account = HostingAccount.objects.create(
name="Example account",
primary_domain="example.com",
customer=Customer.objects.create(user=self.customer),
)
Customer.objects.create(user=self.other)
self.domain = HostingMailDomain.objects.create(
domain="example.com", account=self.account
)
def test_website_usage_is_visible_only_to_the_account_customer(self):
url = reverse("panel:website_usage", args=[self.account.pk])
self.client.force_login(self.customer)
self.assertContains(self.client.get(url), "Usage for Example account")
self.client.force_login(self.other)
self.assertEqual(self.client.get(url).status_code, 404)
self.assertEqual(self.client.post(url).status_code, 404)
def test_queue_is_visible_to_operators_only(self):
url = reverse("panel:mail_queue", args=[self.domain.pk])
self.client.force_login(self.customer)
self.assertEqual(self.client.get(url).status_code, 403)
self.assertEqual(self.client.post(url).status_code, 403)
self.client.force_login(self.operator)
self.assertContains(self.client.get(url), "Mail queue for example.com")
with (
patch(
"coulobre.hosting.mail_queue_views.refresh_mail_queue.delay"
) as send,
self.captureOnCommitCallbacks(execute=True),
):
self.assertEqual(self.client.post(url).status_code, 302)
send.assert_called_once()
+37
View File
@@ -74,6 +74,43 @@ class InstallerParametersTests(unittest.TestCase):
self.assertEqual(plan.mail.host_key, str(path))
self.assertEqual(plan.mail.port, 2222)
def test_remote_bootstrap_shares_a_host_between_roles(self):
with tempfile.TemporaryDirectory() as folder:
key = Path(folder) / "host.pub"
key.write_text("ssh-ed25519 fixture-key\n")
connection = {
"mode": "remote-install",
"host": "192.0.2.41",
"host_key": str(key),
"ssh_user": "operator",
"ssh_identity": "/root/node-install-key",
}
plan = parse_plan(
{
"panel": {
"hostname": "panel.example.net",
"access": "acme",
},
"admin": ADMIN,
"dns": connection,
"mail": connection
| {
"mail_hostname": "mx.example.net",
"tls": "acme",
},
}
)
self.assertEqual(plan.dns.host, plan.mail.host)
self.assertEqual(plan.dns.ssh_user, "operator")
self.assertEqual(plan.mail.host, "192.0.2.41")
self.assertEqual(plan.mail.mail_hostname, "mx.example.net")
self.assertEqual(
plan.mail.key,
"/etc/letsencrypt/live/mx.example.net/privkey.pem",
)
self.assertIn("192.0.2.41", plan.description())
self.assertNotIn("/root/node-install-key", plan.description())
def test_password_file_must_be_private_and_regular(self):
with tempfile.TemporaryDirectory() as folder:
path = Path(folder) / "password"