From c37c3e19a8749e485a6049ef78693ef6a41fed35 Mon Sep 17 00:00:00 2001 From: sabal-whitehat Date: Sun, 13 Jul 2025 18:16:02 -0700 Subject: [PATCH 1/3] feat: improve init script with interactive prompts and modern docker syntax --- data/nginx/{app.conf => app.conf.example} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename data/nginx/{app.conf => app.conf.example} (94%) diff --git a/data/nginx/app.conf b/data/nginx/app.conf.example similarity index 94% rename from data/nginx/app.conf rename to data/nginx/app.conf.example index 52dc0e78..f4173b27 100644 --- a/data/nginx/app.conf +++ b/data/nginx/app.conf.example @@ -23,7 +23,7 @@ server { ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; location / { - proxy_pass http://example.org; + proxy_pass http://your-web-server:3000; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From e65620f48996e814dd73f8040fe536098c7a7347 Mon Sep 17 00:00:00 2001 From: sabal-whitehat Date: Sun, 13 Jul 2025 18:16:51 -0700 Subject: [PATCH 2/3] feat: improve init script with interactive prompts and modern docker syntax --- init-letsencrypt.sh | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/init-letsencrypt.sh b/init-letsencrypt.sh index a3f3cb01..ef746d79 100755 --- a/init-letsencrypt.sh +++ b/init-letsencrypt.sh @@ -1,16 +1,42 @@ #!/bin/bash -if ! [ -x "$(command -v docker-compose)" ]; then - echo 'Error: docker-compose is not installed.' >&2 +if ! [ -x "$(command -v docker)" ]; then + echo 'Error: docker is not installed.' >&2 exit 1 fi -domains=(example.org www.example.org) +# Ask for domain +read -p "Enter your domain (e.g., example.org): " domain +if [ -z "$domain" ]; then + echo "Error: Domain is required." >&2 + exit 1 +fi + +# Ask for webserver URL +read -p "Enter your webserver URL (e.g., http://localhost:3000): " webserver_url +if [ -z "$webserver_url" ]; then + echo "Error: Webserver URL is required." >&2 + exit 1 +fi + +domains=($domain www.$domain) rsa_key_size=4096 data_path="./data/certbot" email="" # Adding a valid address is strongly recommended staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits +# Create nginx configuration file +echo "### Creating nginx configuration file ..." +if [ ! -f "data/nginx/app.conf.example" ]; then + echo "Error: data/nginx/app.conf.example not found." >&2 + exit 1 +fi + +# Create the app.conf file with replacements +sed "s/example.org/$domain/g; s|http://your-web-server:3000|$webserver_url|g" data/nginx/app.conf.example > data/nginx/app.conf +echo "Created data/nginx/app.conf with domain: $domain and webserver URL: $webserver_url" +echo + if [ -d "$data_path" ]; then read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then @@ -30,7 +56,7 @@ fi echo "### Creating dummy certificate for $domains ..." 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' \ @@ -39,11 +65,11 @@ echo echo "### Starting nginx ..." -docker-compose up --force-recreate -d nginx +docker compose up --force-recreate -d nginx echo 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 @@ -66,7 +92,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 \ @@ -77,4 +103,4 @@ docker-compose run --rm --entrypoint "\ echo echo "### Reloading nginx ..." -docker-compose exec nginx nginx -s reload +docker compose exec nginx nginx -s reload From e9be6114882de3eb227ce323b9b16cdb77796b5f Mon Sep 17 00:00:00 2001 From: sabal-whitehat Date: Sun, 13 Jul 2025 18:17:59 -0700 Subject: [PATCH 3/3] Update .gitignore to ignore nginx conf --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 68f5d131..60ae8789 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /data/certbot +/data/nginx/app.conf \ No newline at end of file