mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 10:51:36 -04:00
- Replace nginx with Caddy as the web server for both Docker and native (RPi/Debian) deployments. Caddy handles HTTPS termination, reverse proxying to all services (API, React app, Controller, Kiwix, Help, Map), and serves the media/download file browsers. - Generate a Root CA and signed leaf certificates for HTTPS. The Root CA uses Name Constraints to restrict signing to local addresses only (.local, localhost, and RFC 1918 private IP ranges), mitigating MITM risk if the CA key is compromised. - Add an HTTP landing page that guides users through one-time CA certificate installation on iOS, Android, macOS, Windows, Linux, and Firefox, with auto-redirect when the cert is already trusted. - Add trailing-slash redirects for /controller, /docs, /media, and /download so bare paths don't fall through to the React catch-all. - Add a Root CA download link on the Settings page under Configs. - Update help.sh diagnostics for IPv6 listener detection and HTTP/2 status codes. - Remove all nginx config files and the https_proxy Docker container. - Bump wrolpi-help submodule with certificate documentation.
28 lines
976 B
Bash
28 lines
976 B
Bash
#!/usr/bin/env bash
|
|
# Check if the WROLPi leaf certificate is expired or expiring within 30 days.
|
|
# If so, regenerate it and reload Caddy.
|
|
|
|
set -e
|
|
|
|
CERT_DIR="${CERT_DIR:-/etc/ssl/wrolpi}"
|
|
LEAF_CERT="${CERT_DIR}/cert.crt"
|
|
|
|
if [ ! -f "${LEAF_CERT}" ]; then
|
|
echo "Leaf certificate not found at ${LEAF_CERT}, generating..."
|
|
/opt/wrolpi/scripts/generate_certificates.sh
|
|
systemctl reload caddy || systemctl restart caddy || echo "Warning: failed to reload Caddy"
|
|
exit 0
|
|
fi
|
|
|
|
# Check if cert expires within 30 days.
|
|
if openssl x509 -checkend 2592000 -noout -in "${LEAF_CERT}" 2>/dev/null; then
|
|
echo "Certificate is still valid for more than 30 days, no renewal needed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Certificate is expired or expiring within 30 days, renewing..."
|
|
/opt/wrolpi/scripts/generate_certificates.sh
|
|
|
|
# Reload Caddy to pick up new cert.
|
|
systemctl reload caddy || systemctl restart caddy || echo "Warning: failed to reload Caddy"
|
|
echo "Certificate renewed and Caddy reloaded."
|