-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-ssl.sh
More file actions
74 lines (63 loc) · 2.25 KB
/
setup-ssl.sh
File metadata and controls
74 lines (63 loc) · 2.25 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Script para configurar SSL con Let's Encrypt para outfitlab.com.ar
echo "🔐 Configuración de SSL para outfitlab.com.ar"
echo "=============================================="
# Variables
DOMAIN="outfitlab.com.ar"
EMAIL="tpi8bits@gmail.com" # CAMBIA ESTO por tu email real
echo ""
echo "⚠️ IMPORTANTE: Antes de continuar, asegúrate de que:"
echo " 1. El dominio $DOMAIN apunta a la IP de esta VM"
echo " 2. Los puertos 80 y 443 están abiertos en el firewall"
echo " 3. Docker compose está corriendo (docker compose up -d)"
echo ""
read -p "¿Todo listo? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ Abortado. Configura lo necesario y vuelve a ejecutar."
exit 1
fi
echo ""
echo "📝 Paso 1: Verificando que nginx esté corriendo..."
if ! docker ps | grep -q nginx_proxy; then
echo "❌ Error: nginx_proxy no está corriendo"
echo " Ejecuta: docker compose up -d"
exit 1
fi
echo "✅ Nginx corriendo"
echo ""
echo "📝 Paso 2: Obteniendo certificado SSL..."
echo " Esto puede tardar un minuto..."
docker compose run --rm certbot certonly \
--webroot \
--webroot-path=/var/www/certbot \
--email $EMAIL \
--agree-tos \
--no-eff-email \
-d $DOMAIN \
-d www.$DOMAIN
if [ $? -eq 0 ]; then
echo ""
echo "✅ Certificado obtenido exitosamente!"
echo ""
echo "📝 Paso 3: Cambiando a configuración HTTPS..."
# Cambiar docker-compose.yml para usar nginx.conf en lugar de nginx-simple.conf
sed -i 's|./nginx-simple.conf:/etc/nginx/conf.d/default.conf|./nginx.conf:/etc/nginx/conf.d/default.conf|' docker-compose.yml
echo "📝 Paso 4: Reiniciando nginx con SSL..."
docker compose up -d nginx-proxy
echo ""
echo "🎉 ¡Listo! Tu sitio debería estar accesible en:"
echo " https://$DOMAIN"
echo " https://www.$DOMAIN"
echo ""
echo "📌 El certificado se renovará automáticamente."
echo "📌 HTTP (puerto 80) ahora redirige a HTTPS."
else
echo ""
echo "❌ Error al obtener el certificado."
echo " Verifica que:"
echo " - El dominio $DOMAIN apunte correctamente a esta VM"
echo " - El puerto 80 esté accesible desde internet"
echo " - nginx esté corriendo correctamente"
exit 1
fi