Created
June 18, 2025 02:14
-
-
Save roxsross/2b3fc1c64e70f75a34d7435b2d27d94f to your computer and use it in GitHub Desktop.
script aws girls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dnf update -y | |
dnf install -y nginx unzip python3-certbot-nginx | |
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" 2>/dev/null) | |
PUBLIC_IP=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/public-ipv4 2>/dev/null) | |
if [ -z "$PUBLIC_IP" ]; then | |
PUBLIC_IP=$(curl -s ifconfig.me) | |
fi | |
DOMAIN="${PUBLIC_IP}.sslip.io" | |
# Descargar el sitio web | |
cd /tmp | |
wget https://github.com/startbootstrap/startbootstrap-one-page-wonder/archive/gh-pages.zip | |
unzip gh-pages.zip | |
rm -rf /usr/share/nginx/html/* | |
cp -r startbootstrap-one-page-wonder-gh-pages/* /usr/share/nginx/html/ | |
# Configurar nginx | |
cat > /etc/nginx/conf.d/default.conf << 'EOF' | |
server { | |
listen 80; | |
server_name DOMAIN_PLACEHOLDER; | |
root /usr/share/nginx/html; | |
index index.html; | |
location / { | |
try_files $uri $uri/ /index.html; | |
} | |
} | |
EOF | |
sed -i "s/DOMAIN_PLACEHOLDER/${DOMAIN}/g" /etc/nginx/conf.d/default.conf | |
# Iniciar nginx | |
systemctl enable nginx --now | |
sleep 10 | |
# Obtener certificado SSL con certbot | |
certbot --nginx -d ${DOMAIN} --non-interactive --agree-tos --email [email protected] --redirect | |
# Reiniciar nginx para aplicar SSL | |
systemctl reload nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment