Skip to content

Instantly share code, notes, and snippets.

@kkroesch
Created October 26, 2023 15:16
Show Gist options
  • Save kkroesch/7a0c9de3b63451a9e44280db5255b02b to your computer and use it in GitHub Desktop.
Save kkroesch/7a0c9de3b63451a9e44280db5255b02b to your computer and use it in GitHub Desktop.
HAProxy Certbot
DOMAIN=$1
certbot certonly \
--standalone -d "$DOMAIN" \
--email "helpdesk@$DOMAIN"
--non-interactive \
--agree-tos \
--http-01-port=8899
cp /etc/live/$DOMAIN/fullchain.pem /etc/haproxy/${DOMAIN}.pem
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend ssl
bind *:443 ssl crt /etc/haproxy/lab.kroesch.net.pem no-sslv3
mode tcp
option tcplog
tcp-request inspect-delay 5s
tcp-request content accept if HTTP
acl letsencrypt-acl path_beg /.well-known/acme-challenge/
use_backend letsencrypt-backend if letsencrypt-acl
use_backend secure_http if HTTP
#---------------------------------------------------------------------
# Certbot backend
#---------------------------------------------------------------------
backend letsencrypt-backend
server certbot 127.0.0.1:8899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment