Skip to content

Instantly share code, notes, and snippets.

@turikhay
Last active September 8, 2023 19:18
Show Gist options
  • Save turikhay/913a5592b5f6012bf53eb9edfd64aa2e to your computer and use it in GitHub Desktop.
Save turikhay/913a5592b5f6012bf53eb9edfd64aa2e to your computer and use it in GitHub Desktop.
HAProxy + Letsencrypt
certbot certonly \
    --dry-run \
    --agree-tos \
    --run-deploy-hooks \
    --deploy-hook /path/to/letsencrypt_haproxy_hook.sh \
    --standalone \
    --preferred-challenges http-01 \
    --http-01-port 54321 \
    -d ...
frontend fe
bind *:80
# Enable after successful certificate issue
# bind *:443 ssl crt /etc/ssl/private/<domain>.pem
acl letsencrypt-acl path_beg /.well-known/acme-challenge/
use_backend le if letsencrypt-acl
default_backend proxy
backend le
server letcencrypt 127.0.0.1:54321
#!/bin/sh
#
# Original author: Olivier M. (@gqdc)
# Source: https://github.com/gqdc/certbot-haproxy-hooks
#
#
IFS=' '
CRT_FOLDER="/etc/ssl/private"
for domain in $RENEWED_DOMAINS; do
cd $RENEWED_LINEAGE
cat fullchain.pem privkey.pem > $CRT_FOLDER/$domain.pem
done
systemctl reload haproxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment