Skip to content

Commit 7e580b2

Browse files
FIX: Letsencrypt allow for multi-domain renewal
With DISCOURSE_HOSTNAME of example.com... multiple domains are not able to renew if they cannot access such as http://alternate.example.com which redirects under the current https config. Allow .well-known on http to continue to serve traffic sans https for letsencrypt renewals FIX: better listening for ipv6 for ipv4 only
1 parent 7f8d8b9 commit 7e580b2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

templates/web.letsencrypt.ssl.template.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ run:
2626
LE_WORKING_DIR="${LETSENCRYPT_DIR}" ./acme.sh --upgrade --auto-upgrade
2727
LE_WORKING_DIR="${LETSENCRYPT_DIR}" ./acme.sh --set-default-ca --server letsencrypt
2828
29+
cat << EOF > /etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf
30+
server {
31+
listen 80;
32+
33+
location ~ /.well-known {
34+
root /var/www/discourse/public;
35+
allow all;
36+
}
37+
location / {
38+
return 301 https://${DISCOURSE_HOSTNAME}$request_uri;
39+
}
40+
}
41+
EOF
42+
2943
cat << EOF > /etc/nginx/letsencrypt.conf
3044
user www-data;
3145
worker_processes auto;
@@ -48,7 +62,6 @@ run:
4862
4963
server {
5064
listen 80;
51-
listen [::]:80;
5265
5366
location ~ /.well-known {
5467
root /var/www/discourse/public;
@@ -58,6 +71,12 @@ run:
5871
}
5972
EOF
6073
74+
if [ -f "/proc/net/if_inet6" ] ; then
75+
sed -i 's/listen 80;/listen 80;\nlisten [::]:80;/g' /etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf
76+
sed -i 's/listen 80;/listen 80;\nlisten [::]:80;/g' /etc/nginx/letsencrypt.conf
77+
fi
78+
79+
6180
sed -Ei "s/^#?ACCOUNT_EMAIL=.+/ACCOUNT_EMAIL=${LETSENCRYPT_ACCOUNT_EMAIL}/" \
6281
/shared/letsencrypt/account.conf
6382

0 commit comments

Comments
 (0)