Skip to content

Commit

Permalink
feat: Add script for SSL automatic generation
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Sep 4, 2023
1 parent 284be21 commit 62b73b6
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ services:
image: nginx:latest
volumes:
- ./nginx/nginx.prod.conf:/etc/nginx/nginx.conf
- /etc/letsencrypt:/etc/letsencrypt:ro
- ./letsencrypt:/etc/letsencrypt:ro
- ./public:/var/www:rw
ports:
- "80:80"
- "443:443"
Expand Down Expand Up @@ -54,5 +55,12 @@ services:
command: --cleanup --interval 120 uvlhub-web-1
restart: always

certbot:
image: certbot/certbot
container_name: certbot
volumes:
- ./public:/var/www:rw
- ./letsencrypt:/etc/letsencrypt

volumes:
db_data:
2 changes: 2 additions & 0 deletions letsencrypt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
5 changes: 5 additions & 0 deletions nginx/nginx.prod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ http {
listen 80;
server_name uvlhub.io;

location ~ /.well-known/acme-challenge/ {
root /var/www;
try_files $uri =404;
}

location / {
return 301 https://www.uvlhub.io$request_uri;
}
Expand Down
2 changes: 2 additions & 0 deletions public/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
3 changes: 3 additions & 0 deletions ssl_renew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose -f docker-compose.prod.yml run certbot renew --webroot --webroot-path=/var/www
28 changes: 28 additions & 0 deletions ssl_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

while true; do
# Prompt for domain and email
echo "Enter your domain (including 'www' and '.com' or '.org' or whatever the extension). Example: www.exampledomain.com"
read domain

echo "Enter your email: "
read email

# Display a summary of the entered data and ask for confirmation
echo "Configured with the domain $domain"
echo "Configured with the email $email"
echo ""
echo "Are you sure the entered information is correct? [y/n]"
read confirm

# If the user confirms, break the loop and continue with the script. Otherwise, repeat the loop.
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
break
else
echo "Please re-enter the information."
echo ""
fi
done

# Generate the certificate
docker compose -f docker-compose.prod.yml run certbot certonly --webroot --webroot-path=/var/www -d $domain --email $email --agree-tos --no-eff-email --force-renewal

0 comments on commit 62b73b6

Please sign in to comment.