Feature/site https #20

Merged
parkel merged 2 commits from feature/site-https into main 2026-11-21 02:43:50 +01:00
5 changed files with 87 additions and 0 deletions
Showing only changes of commit 3be2f8fd07 - Show all commits

No files matched your search

+1
View File
@@ -43,6 +43,7 @@ jobs:
ruff check .
ruff format --check .
sh -n tests/web-node/smoke.sh
sh -n deploy/certbot/reload-apache.sh
- name: Check Django configuration and migrations
run: |
+7
View File
@@ -0,0 +1,7 @@
Alias "/.well-known/acme-challenge/" "/var/www/coulobre-acme/.well-known/acme-challenge/"
<Directory "/var/www/coulobre-acme/.well-known/acme-challenge">
AllowOverride None
Options None
Require all granted
</Directory>
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
set -eu
case "${RENEWED_LINEAGE:-}" in
/etc/letsencrypt/live/coulobre-*)
lock=/var/lib/coulobre/web-node/apply.lock
if [ -f "$lock" ]; then
exec 9<"$lock"
flock -x 9
/usr/sbin/apache2ctl configtest 2>&1
/usr/sbin/service apache2 reload
fi
;;
esac
+7
View File
@@ -212,6 +212,13 @@ The worker applies the domain shown in the preview. If the account's primary
domain changes before the worker starts, create a preview for the new domain.
An existing web node reservation stays bound to the domain it was created for.
## Enable HTTPS for hosted websites
Once a site is active, obtain the website certificate with Certbot on the
web node and enable its HTTPS virtual host. Each site uses its own
certificate. The renewal hook reloads Apache after Certbot renews it.
[Hosted website HTTPS setup](development.md#enable-https-for-a-hosted-website)
## Provision local databases from the panel
Enable the [database provisioning socket](development.md#enable-local-database-provisioning)
+58
View File
@@ -670,6 +670,63 @@ The status command reads local state. It exits with code 0 for `configured`,
code 2 for the other report states, and code 1 if it cannot read the manifest
or inspect the node. Use an HTTP request to verify the site's response as well.
### Enable HTTPS for a hosted website
Apply the web deployment manifest first. Use Certbot to obtain and renew
the website's Let's Encrypt certificate. The HTTP-01 challenge requires
public DNS for the domain and an inbound connection on port 80. If a
reverse proxy handles that port, forward `/.well-known/acme-challenge/`
for the domain to the web node, preserving the host and path.
[Let's Encrypt challenge types](https://letsencrypt.org/docs/challenge-types/)
Prepare Apache and the shared challenge directory once per web node.
Apache serves challenge files from this directory, which the web node
operator controls.
```sh
sudo apt install certbot
sudo a2enmod ssl
sudo install -d -m 0755 /var/www/coulobre-acme/.well-known/acme-challenge
sudo install -m 0644 deploy/apache/acme.conf.example \
/etc/apache2/conf-available/coulobre-acme.conf
sudo a2enconf coulobre-acme
sudo apache2ctl configtest
sudo systemctl reload apache2
```
Use the manifest's account ID for the Certbot certificate name and its
primary domain for the certificate hostname. Keep Certbot's private key
root-owned with mode `0600`. Apache uses the managed Certbot lineage on
port 443, with the same document root and PHP-FPM pool as the HTTP site.
```sh
sudo certbot certonly --webroot --webroot-path /var/www/coulobre-acme \
--cert-name coulobre-1 --domains example.org
sudo /opt/coulobre/bin/coulobre-web-node enable-https coulobre-web-plan-1.json
sudo /opt/coulobre/bin/coulobre-web-node https-status coulobre-web-plan-1.json
curl --fail https://example.org/
```
`https-status` checks the local virtual host and certificate on disk.
An HTTPS request verifies the certificate and response clients receive.
HTTP remains available for the site and future HTTP-01 challenges.
Install the renewal hook and check the Certbot timer. After a successful
renewal of a Coulobre certificate, the hook validates the Apache
configuration and reloads the service.
```sh
sudo install -D -m 0755 deploy/certbot/reload-apache.sh \
/etc/letsencrypt/renewal-hooks/deploy/coulobre-apache
systemctl status certbot.timer
sudo certbot renew --dry-run --run-deploy-hooks --cert-name coulobre-1
```
For a public domain that cannot accept inbound HTTP on port 80, Certbot
can use a DNS plugin for validation. Request the certificate under the
same lineage name before running `enable-https`.
[Certbot certificate guide](https://eff-certbot.readthedocs.io/en/stable/using.html)
### Enable local web activation
On a web node with the same Apache and PHP-FPM setup, systemd can accept local
@@ -741,6 +798,7 @@ fixtures. Then run the checks from the repository root.
ruff check .
ruff format --check .
sh -n tests/web-node/smoke.sh
sh -n deploy/certbot/reload-apache.sh
python manage.py check
python manage.py makemigrations --check --dry-run
python manage.py test coulobre