Wiki » Debian konfiguracja usług »
Konfiguracja HAProxy PokażUkryj
Dodanie SSL na 443 w sekcji frontend
#bind :443 ssl crt /etc/letsencrypt/live/fullchains/fullchain.pem
Dodanie przekierowania w sekcji frontend:
acl is_letsencrypt-acl path_beg /.well-known/acme-challenge/ use_backend letsencrypt-backend if is_letsencrypt-acl
Dodanie backend:
backend letsencrypt-backend server letsencrypt 127.0.0.1:8888
Dodanie przekierowanie HTTP do HTTPS w sekcji frontend
http-request redirect scheme https unless { ssl_fc }
Przykład pełnego wpisu
frontend http-in
bind :80
#bind :443 ssl crt /etc/letsencrypt/live/fullchains/cert.pem
mode http
http-request redirect scheme https unless { ssl_fc }
# Strip port from Host header
http-request replace-value Host (.*):.* \1
acl is_letsencrypt-acl path_beg /.well-known/acme-challenge/
use_backend letsencrypt-backend if is_letsencrypt-acl
backend letsencrypt-backend
server letsencrypt 127.0.0.1:8888
Pobranie konfiguracji przez certbot PokażUkryj
echo -e '#!/bin/bash -x' "\n\n" >> /etc/haproxy/certbot.sh
echo "certbot -m webmaster@justnet.pl --agree-tos; certonly --standalone --preferred-challenges http-01 --http-01-port 8888 --http-01-address 127.0.0.1 -d domain1.xyz -d domain1.xyz" >> /etc/haproxy/certbot.sh; \
chmod +x /etc/haproxy/certbot.sh; \
bash /etc/haproxy/certbot.sh; \
\
for domain in `find /etc/letsencrypt/live/* -maxdepth 1 -type d|xargs`; do ln -s ${domain}/privkey.pem ${domain}/fullchain.pem.key; done;
Podajemy port 8888 na którym słucha certbot, na port 8888 zostanie przekierowane zapytanie przez HAProxy z portu 80