From 6321755a6013ea9760a60a107467ce072ae31c7a Mon Sep 17 00:00:00 2001 From: Eray Date: Fri, 24 Mar 2023 12:57:11 +0300 Subject: [PATCH 1/4] Updated for Docker Compose V2 --- init-letsencrypt.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/init-letsencrypt.sh b/init-letsencrypt.sh index a3f3cb01..224c856d 100755 --- a/init-letsencrypt.sh +++ b/init-letsencrypt.sh @@ -1,7 +1,7 @@ #!/bin/bash -if ! [ -x "$(command -v docker-compose)" ]; then - echo 'Error: docker-compose is not installed.' >&2 +if ! [ -x "$(command -v docker compose)" ]; then + echo 'Error: docker compose is not installed.' >&2 exit 1 fi @@ -30,7 +30,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 +39,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 +66,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 +77,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 4a9174847763042fcb4fce29ded96c35e18d30c6 Mon Sep 17 00:00:00 2001 From: Eray Date: Fri, 24 Mar 2023 13:04:45 +0300 Subject: [PATCH 2/4] =?UTF-8?q?From=20the=20end=20of=20June=202023=20Compo?= =?UTF-8?q?se=20V1=20won=E2=80=99t=20be=20supported=20anymore=20and=20will?= =?UTF-8?q?=20be=20removed=20from=20all=20Docker=20Desktop=20versions.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c3bd886..5c66c48c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This is useful when you need to set up nginx as a reverse proxy for an application. ## Installation -1. [Install docker-compose](https://docs.docker.com/compose/install/#install-compose). +1. [Install docker engine](https://docs.docker.com/engine/install/). 2. Clone this repository: `git clone https://github.com/wmnnd/nginx-certbot.git .` @@ -24,7 +24,7 @@ application. 5. Run the server: - docker-compose up + docker compose up ## Got questions? Feel free to post questions in the comment section of the [accompanying guide](https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71) From ffd546998795e258b3b2ab0756b4efeb576419d0 Mon Sep 17 00:00:00 2001 From: Eray Date: Fri, 24 Mar 2023 14:14:38 +0300 Subject: [PATCH 3/4] Developers, now, can edit sh file in terminal, simply, answering the questions. --- README.md | 6 ++++-- init-letsencrypt.sh | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c66c48c..360f0bee 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,15 @@ application. 2. Clone this repository: `git clone https://github.com/wmnnd/nginx-certbot.git .` 3. Modify configuration: -- Add domains and email addresses to init-letsencrypt.sh -- Replace all occurrences of example.org with primary domain (the first one you added to init-letsencrypt.sh) in data/nginx/app.conf +- Replace all occurrences of example.org with primary domain (the first one you will add to init-letsencrypt.sh) in data/nginx/app.conf 4. Run the init script: ./init-letsencrypt.sh +5. Answer prompt questions in terminal +- Domains, Email, Testing. + 5. Run the server: docker compose up diff --git a/init-letsencrypt.sh b/init-letsencrypt.sh index 224c856d..247a27be 100755 --- a/init-letsencrypt.sh +++ b/init-letsencrypt.sh @@ -11,6 +11,20 @@ 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 +read -p "Enter Domains (with spaces between each domain): " domains +read -p "Enter email (Adding a valid address is strongly recommended): " email +read -p "Are you testing(y/N): " -n 1 -r + +if [[ $REPLY =~ ^[Yy]$ ]] +then + echo + staging=1 +fi + +echo "Domains: $domains" +echo "Email: $email" +echo "Testing: $staging" + 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 From 5a42a9dfd01cba987b18f383c774e2787ae5b588 Mon Sep 17 00:00:00 2001 From: Eray <36801647+eademir@users.noreply.github.com> Date: Fri, 24 Mar 2023 14:15:49 +0300 Subject: [PATCH 4/4] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 360f0bee..ada5faf0 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ application. 5. Answer prompt questions in terminal - Domains, Email, Testing. -5. Run the server: +6. Run the server: docker compose up