WIUNIX ACADEMY
HAProxy with Let’s Encrypt and validated certificate renewal
Page 4 of 5. Review the earlier steps and prerequisites before continuing.
YOUR SYSTEM. YOUR STEPS.
Where are you working?
Choose your OS and version. The prerequisites, commands and troubleshooting follow your environment.
USE YOUR OWN VALUES
Configure this tutorial
Set the example values for your environment; related explanations and copy panels update together. Never enter passwords, private keys or tokens. Values stay in this tab and are not sent to the server or share links. Check actual DNS, certificates and network policy before running commands.
Different IP addresses, domains or ports? Open the settings below, change the values and select “Apply to tutorial”, then copy the updated commands.
Set values for my environment7 editable values
LET’S BUILD
Exercise the deployment and separate dry-run behavior
First redeploy the current trusted certificate through the hook; this tests its real validation and reload path without asking for a new certificate. Then run Certbot renewal dry-run against staging. Deploy hooks are normally skipped by dry-run; --run-deploy-hooks explicitly runs them with the current active certificate, not the untrusted staging certificate. Do not claim an actual renewal from this simulation. Verify public TLS again after hook execution.
Bash on dedicated edge VM; external checks noted in text
set -eu
sudo python3 -m py_compile '/srv/academy-haproxy-tls/deploy.py'
sudo env RENEWED_LINEAGE='/srv/academy-haproxy-tls/acme/config/live/app.example.com' '/srv/academy-haproxy-tls/deploy.py'
sudo /usr/bin/certbot renew --dry-run --run-deploy-hooks --cert-name 'app.example.com' \
--config-dir '/srv/academy-haproxy-tls/acme/config' --work-dir '/srv/academy-haproxy-tls/acme/work' \
--logs-dir '/srv/academy-haproxy-tls/acme/logs' --deploy-hook '/srv/academy-haproxy-tls/deploy.py'
curl --noproxy '*' --fail --show-error 'https://app.example.com/'
The current trusted PEM reloads; a successful CA dry run explicitly invokes the hook and the public certificate remains trusted.
LET’S BUILD
Use one dedicated renewal schedule
Use only the dedicated schedule for this lineage. Vendor unit names were masked before installing packages on the otherwise empty disposable VM; never modify schedules serving other certificates on a shared host. The distinct academy service uses root and the private config/work/log paths; no key permission workaround is needed.
Bash on dedicated edge VM; external checks noted in text
set -eu
test ! -e /etc/systemd/system/academy-certbot.service
test ! -L /etc/systemd/system/academy-certbot.service
sudo install -m 0644 /dev/null /etc/systemd/system/academy-certbot.service
test ! -e /etc/systemd/system/academy-certbot.timer
test ! -L /etc/systemd/system/academy-certbot.timer
sudo install -m 0644 /dev/null /etc/systemd/system/academy-certbot.timer
sudo nano /etc/systemd/system/academy-certbot.service /etc/systemd/system/academy-certbot.timer
Both new scheduler files are ready; the next two panels define the exact executable and schedule.
LET’S BUILD
Dedicated Certbot service
Save this complete unit file.
File on the dedicated edge VM
[Unit]
Description=Renew the Academy HAProxy certificate
After=network-online.target academy-acme-webroot.service academy-haproxy.service
Requires=academy-acme-webroot.service academy-haproxy.service
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/certbot renew --config-dir /srv/academy-haproxy-tls/acme/config --work-dir /srv/academy-haproxy-tls/acme/work --logs-dir /srv/academy-haproxy-tls/acme/logs --cert-name app.example.com --deploy-hook /srv/academy-haproxy-tls/deploy.py --quiet
The unit uses only the dedicated article lineage.
LET’S BUILD
Twice-daily timer with jitter
Save this complete unit file.
File on the dedicated edge VM
[Unit]
Description=Check the Academy certificate twice daily
[Timer]
OnCalendar=*-*-* 00,12:00:00
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
The unit uses only the dedicated article lineage.
LET’S BUILD
Enable scheduling and monitor the served expiry
Enable the dedicated units after successful manual probes. Monitor timer failures, Certbot logs, the actual served certificate fingerprint/expiry and backend readiness from outside the edge. A timer listed as active does not prove issuance, successful hook execution or the loaded certificate. Maintain a protected off-host backup of ACME account/lineage, configs and the last trusted PEM; no restore drill or reboot was performed for this article. A deploy-hook error does not necessarily make issuance or the overall Certbot exit code fail; inspect its journal and the actually served certificate independently.
Bash on dedicated edge VM; external checks noted in text
set -euo pipefail
sudo systemctl daemon-reload
sudo systemctl enable academy-haproxy.service academy-acme-webroot.service
sudo systemctl enable --now academy-certbot.timer
sudo systemctl list-timers --all academy-certbot.timer
sudo journalctl -u academy-certbot.service -n 60 --no-pager
openssl s_client -connect 'app.example.com:443' -servername 'app.example.com' -verify_hostname 'app.example.com' -verify_return_error -CAfile /etc/ssl/certs/ca-certificates.crt </dev/null 2>/dev/null | openssl x509 -noout -dates -fingerprint -sha256
The next trigger is visible; trusted public certificate dates/fingerprint are observable and alert ownership is assigned.
LET’S BUILD
Diagnose the failing boundary without hiding it
For authorization errors compare public A/AAAA, exact token bytes, CAA and external port80 reachability before retrying. A404 indicates routing/webroot; a308 on the token indicates the exception is wrong. For503 inspect both readiness responses and firewall/source policy. Do not weaken checks to make an unhealthy dependency appear healthy. For TLS errors inspect chain/SAN/key/permissions and the selected SNI; never use curl -k as acceptance. For hook failure compare current lineage and served fingerprint, repair the hook and redeploy the already renewed certificate.
Bash on dedicated edge VM; external checks noted in text
sudo /usr/sbin/haproxy -c -f '/srv/academy-haproxy-tls/haproxy.cfg'
sudo journalctl -u academy-haproxy.service -u academy-acme-webroot.service -u academy-certbot.service -n 100 --no-pager
sudo ss -lntp
sudo stat -c '%a %U:%G %n' '/srv/academy-haproxy-tls/certs' '/srv/academy-haproxy-tls/certs/app.example.com.pem'
curl --noproxy '*' --fail -H 'Host: app.example.com' 'http://10.77.0.21:8080/health/ready'
curl --noproxy '*' --fail -H 'Host: app.example.com' 'http://10.77.0.22:8080/health/ready'
dig CAA 'app.example.com'
Logs and probes identify DNS/challenge, TLS/deploy or backend failure separately; failing commands remain visible.