-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcertbot-setup.sh
More file actions
executable file
·35 lines (29 loc) · 1.03 KB
/
Copy pathcertbot-setup.sh
File metadata and controls
executable file
·35 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -e
echo "🔒 Setting up Let's Encrypt SSL Certificates"
echo "============================================="
# Install certbot if not present
if ! command -v certbot &> /dev/null; then
echo "Installing certbot..."
sudo apt-get update
sudo apt-get install -y certbot python3-certbot-nginx
fi
# Domain configuration
DOMAIN=${DOMAIN:-"farmer-platform.example.com"}
EMAIL=${SSL_EMAIL:-"admin@example.com"}
echo "Obtaining SSL certificate for $DOMAIN..."
sudo certbot certonly --standalone \
--non-interactive \
--agree-tos \
--email "$EMAIL" \
-d "$DOMAIN" \
-d "api.$DOMAIN" \
-d "temporal.$DOMAIN" \
-d "grafana.$DOMAIN"
# Set up auto-renewal
echo "Setting up automatic renewal..."
sudo tee /etc/cron.d/certbot-renew << EOF
0 0,12 * * * root certbot renew --quiet --post-hook "docker-compose -f /home/ubuntu/farmer-data-collection/docker-compose.production.yml restart apisix"
EOF
echo "✓ SSL certificates configured successfully!"
echo "Certificate location: /etc/letsencrypt/live/$DOMAIN/"