Skip to content
local-cert
Browse the documentation

HAProxy

The proven route: acme.sh obtains the certificate and its haproxy hook assembles the PEM file HAProxy expects, then reloads the service.

ValueWhere to find itIn this guide
ACME directoryfixed for each instancehttps://certs.example.com/acme/directory
Key ID (kid)Keys & access → EAB credentialseab_XXXXXXXXXXXXXXXX
HMAC keyshown only once, at creationCLE_HMAC

1. Account and issuance

acme.sh
acme.sh --register-account --server https://certs.example.com/acme/directory \
  --eab-kid eab_XXXXXXXXXXXXXXXX --eab-hmac-key CLE_HMAC -m ops@example.com

mkdir -p /var/lib/acme-webroot
acme.sh --issue --server https://certs.example.com/acme/directory \
  -d nas.home.example.com -w /var/lib/acme-webroot

The webroot folder doesn't have to be served by HAProxy: local-cert never reads the challenge.

2. Deploy to HAProxy

acme.sh — haproxy hook
export DEPLOY_HAPROXY_PEM_PATH=/etc/haproxy/certs
export DEPLOY_HAPROXY_RELOAD="systemctl reload haproxy"
acme.sh --deploy -d nas.home.example.com --deploy-hook haproxy

The hook writes /etc/haproxy/certs/nas.home.example.com.pem (certificate, chain and key combined). Both variables are remembered: every renewal run by acme.sh's cron job redeploys and reloads.

3. The frontend

/etc/haproxy/haproxy.cfg (excerpt)
frontend https
    bind :443 ssl crt /etc/haproxy/certs/
    http-request set-header X-Forwarded-Proto https
    use_backend nas if { hdr(host) -i nas.home.example.com }

backend nas
    server nas 192.168.1.50:5000