more LE fixes

This commit is contained in:
Matthew Hodgson
2024-11-08 16:47:59 +00:00
parent ba0cc617ea
commit 71f75417ac
3 changed files with 15 additions and 23 deletions

View File

@@ -85,8 +85,6 @@ services:
depends_on:
init:
condition: service_completed_successfully
synapse:
condition: service_started
certbot:
image: certbot/certbot:latest
@@ -95,11 +93,6 @@ services:
- ${VOLUME_PATH}/data/certbot/conf:/etc/letsencrypt
- ${VOLUME_PATH}/data/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while [ -e /etc/letsencrypt/live ]; do certbot renew; sleep 12h & wait $${!}; done;'"
depends_on:
init:
condition: service_completed_successfully
nginx:
condition: service_started
postgres:
image: postgres:latest

View File

@@ -14,14 +14,12 @@ server {
listen 80;
# location /.well-known/acme-challenge/ {
# root /var/www/certbot;
# add_header Access-Control-Allow-Origin *;
# }
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location /.well-known/matrix/ {
root /var/www;
#add_header Access-Control-Allow-Origin *;
}
# XXX: is this right? or should auth.$DOMAIN be the issuer?
@@ -29,7 +27,6 @@ server {
proxy_pass http://mas:8080;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr;
#add_header Access-Control-Allow-Origin *;
}
location / {
@@ -45,7 +42,6 @@ server {
location /.well-known/matrix/ {
root /var/www;
#add_header Access-Control-Allow-Origin *;
}
# XXX: is this right? or should auth.$DOMAIN be the issuer?
@@ -53,7 +49,6 @@ server {
proxy_pass http://mas:8080;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr;
#add_header Access-Control-Allow-Origin *;
}
}

View File

@@ -2,8 +2,10 @@
# taken from https://raw.githubusercontent.com/wmnnd/nginx-certbot/refs/heads/master/init-letsencrypt.sh
if ! [ -x "$(command -v docker-compose)" ]; then
echo 'Error: docker-compose is not installed.' >&2
set -x
if ! [ -x "$(command -v docker)" ]; then
echo 'Error: dockeris not installed.' >&2
exit 1
fi
@@ -12,7 +14,7 @@ domains=$DOMAINS
rsa_key_size=4096
data_path="./data/certbot"
read -p "admin email address for letsencrypt: " email
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits
staging=1 # Set to 1 if you're testing your setup to avoid hitting request limits
if [ -d "$data_path" ]; then
read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision
@@ -33,7 +35,7 @@ echo "### Creating dummy certificate for $domains ..."
# N.B. in bash, $domains will return the first value of the array in string context, so this is not a bug:
path="/etc/letsencrypt/live/$domains"
mkdir -p "$data_path/conf/live/$domains"
docker-compose run --rm --entrypoint "\
docker compose run --rm --entrypoint "\
openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1\
-keyout '$path/privkey.pem' \
-out '$path/fullchain.pem' \
@@ -42,11 +44,13 @@ docker-compose run --rm --entrypoint "\
echo
echo "### Starting nginx ..."
docker-compose up --force-recreate -d nginx
docker compose up --force-recreate -d nginx
echo
exit
echo "### Deleting dummy certificate for $domains ..."
docker-compose run --rm --entrypoint "\
docker compose run --rm --entrypoint "\
rm -Rf /etc/letsencrypt/live/$domains && \
rm -Rf /etc/letsencrypt/archive/$domains && \
rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot
@@ -69,7 +73,7 @@ esac
# Enable staging mode if needed
if [ $staging != "0" ]; then staging_arg="--staging"; fi
docker-compose run --rm --entrypoint "\
docker compose run --rm --entrypoint "\
certbot certonly --webroot -w /var/www/certbot \
$staging_arg \
$email_arg \
@@ -80,4 +84,4 @@ docker-compose run --rm --entrypoint "\
echo
echo "### Reloading nginx ..."
docker-compose exec nginx nginx -s reload
docker compose exec nginx nginx -s reload