Add Certbot webroot setup and Apache renewal hook
This commit is contained in:
1 parent
62df077225
commit
3be2f8fd07
5 files changed
+87
No files matched your search
@@ -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: |
|
||||
|
||||
@@ -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>
|
||||
Executable
+14
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user