Kaynağa Gözat

fix: Initial certbot without HAProxy

master
Bingen Eguzkitza 3 ay önce
ebeveyn
işleme
f2d53a0309
3 değiştirilmiş dosya ile 3 ekleme ve 37 silme
  1. +1
    -1
      images/haproxy/haproxy.cfg
  2. +0
    -19
      images/haproxy/haproxy_letsencrypt.cfg
  3. +2
    -17
      images/haproxy/startup.sh

+ 1
- 1
images/haproxy/haproxy.cfg Dosyayı Görüntüle

@@ -101,4 +101,4 @@ backend letsencrypt-backend

#listen admin
# bind 127.0.0.1:8080
# stats enable
# stats enable

+ 0
- 19
images/haproxy/haproxy_letsencrypt.cfg Dosyayı Görüntüle

@@ -1,19 +0,0 @@
defaults
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms

# The frontend only listens on port 80
# If it detects a LetsEncrypt request, is uses the LE backend
frontend fe-letsencrypt
bind *:80

# Test URI to see if its a letsencrypt request
acl letsencrypt-acl path_beg /.well-known/acme-challenge/
use_backend letsencrypt-backend if letsencrypt-acl

default_backend letsencrypt-backend

# LE Backend
backend letsencrypt-backend
server letsencrypt 127.0.0.1:8888

+ 2
- 17
images/haproxy/startup.sh Dosyayı Görüntüle

@@ -1,19 +1,11 @@
#!/bin/bash

CFG_FILE=/etc/haproxy/haproxy.cfg
CFG_LE_FILE=/etc/haproxy/haproxy_letsencrypt.cfg
LETSENCRYPT_PORT=8888

mkdir -p /etc/letsencrypt/haproxy

# Let's Encrypt

# Following these instructions:
# https://serversforhackers.com/c/letsencrypt-with-haproxy

# Start temporary HAProxy
haproxy -f $CFG_LE_FILE -D -p /tmp/haproxy.pid

# Get Let's Encrypt certificates
HAPROXY_CERTS=""
SERVER_NAMES="${NEXTCLOUD_SERVER_NAME} ${GITEA_SERVER_NAME} ${BLOG_1_SERVER_NAME} ${HAUK_SERVER_NAME}"
@@ -25,9 +17,8 @@ for domain in ${DOMAINS}; do
HAPROXY_CERTS="${HAPROXY_CERTS} crt /etc/letsencrypt/haproxy/${_URL}.pem";
if [[ ! -s /etc/letsencrypt/haproxy/${_URL}.pem ]]; then
# Query Let's Encrypt
certbot certonly -d ${_URL} \
--email ${ADMIN_EMAIL} --non-interactive --agree-tos \
--standalone --http-01-port=${LETSENCRYPT_PORT}
certbot certonly --standalone -d ${_URL} \
--email admin@${domain} --non-interactive --agree-tos
if [ $? -eq 0 ]; then
cat /etc/letsencrypt/live/${_URL}/fullchain.pem \
/etc/letsencrypt/live/${_URL}/privkey.pem \
@@ -46,12 +37,6 @@ sed -i "s/\${HAUK_SERVER_NAME}/${HAUK_SERVER_NAME}/g" $CFG_FILE
#echo sed -i "s/\${HAPROXY_CERTS}/${HAPROXY_CERTS}/g" ${CFG_FILE}
sed -i "s/\${HAPROXY_CERTS}/${HAPROXY_CERTS//\//\\/}/g" ${CFG_FILE}

#cat ${CFG_FILE}

echo Killing haproxy `cat /tmp/haproxy.pid`
kill -SIGTERM `cat /tmp/haproxy.pid`
rm /tmp/haproxy.pid

# Create renew cron job
mv /usr/local/bin/letsencrypt.cron /etc/cron.daily/letsencrypt
# remove default cron job

Yükleniyor…
İptal
Kaydet