Requisitos previos
- Un VPS Linux (Ubuntu 22.04 LTS, Rocky Linux 9, o similar)
- Acceso SSH como root o usuario con sudo
- Un dominio apuntando a la IP de tu servidor (registro A en tu DNS)
- El dominio debe propagar antes de emitir el certificado (~5-15 minutos)
Nota: Los comandos de instalación varían según el sistema operativo. Esta guía cubre Ubuntu/Debian y Rocky Linux/AlmaLinux/RHEL. Usá los comandos correspondientes a tu distribución.
Paso 1: Actualizar el sistema
Ubuntu / Debian:
apt update && apt upgrade -y
Rocky Linux / AlmaLinux / RHEL:
dnf update -y
Paso 2: Instalar Nginx
Ubuntu / Debian:
apt install nginx -y
systemctl enable nginx
systemctl start nginx
Rocky Linux / AlmaLinux / RHEL:
dnf install nginx -y
systemctl enable nginx
systemctl start nginx
Verificá que esté corriendo:
systemctl status nginx
Ahora si entrás a http://TU_IP desde el navegador deberías ver la página de bienvenida de Nginx.
Paso 3: Configurar el firewall
Ubuntu / Debian (UFW):
ufw allow 'Nginx Full'
ufw allow OpenSSH
ufw enable
Rocky Linux / AlmaLinux / RHEL (firewalld):
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
Paso 4: Crear el virtual host (server block)
nano /etc/nginx/sites-available/tusitioweb.com
Pegá esta configuración base:
server {
listen 80;
listen [::]:80;
server_name tusitioweb.com www.tusitioweb.com;
root /var/www/tusitioweb.com;
index index.html index.php;
location / {
try_files $uri $uri/ =404;
}
}
Creá el directorio del sitio:
mkdir -p /var/www/tusitioweb.com
echo "<h1>Funciona!</h1>" > /var/www/tusitioweb.com/index.html
Activá el sitio:
ln -s /etc/nginx/sites-available/tusitioweb.com /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx
Paso 5: Instalar Certbot y emitir el certificado SSL
Ubuntu / Debian:
apt install certbot python3-certbot-nginx -y
Rocky Linux / AlmaLinux / RHEL:
dnf install epel-release -y
dnf install certbot python3-certbot-nginx -y
Emitir el certificado (igual en todas las distros):
certbot --nginx -d tusitioweb.com -d www.tusitioweb.com
Certbot te va a preguntar:
- Tu email (para avisos de vencimiento)
- Si aceptás los términos de servicio →
Y
Luego automáticamente:
- Verifica que sos dueño del dominio
- Emite el certificado
- Modifica la config de Nginx para activar HTTPS
- Configura la redirección de HTTP → HTTPS
Paso 6: Verificar la renovación automática
Los certificados de Let’s Encrypt duran 90 días y se renuevan automáticamente.
systemctl status certbot.timer
certbot renew --dry-run
Si no hay errores, la renovación automática está configurada correctamente.
Configuración de Nginx para producción
server {
listen 80;
server_name tusitioweb.com www.tusitioweb.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name tusitioweb.com www.tusitioweb.com;
ssl_certificate /etc/letsencrypt/live/tusitioweb.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tusitioweb.com/privkey.pem;
root /var/www/tusitioweb.com;
index index.html;
gzip on;
gzip_types text/plain text/css application/json application/javascript;
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location / {
try_files $uri $uri/ =404;
}
}
Configurar un proxy reverso (Node.js, Laravel, etc.)
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
Verificar que todo está bien
# Estado de Nginx
systemctl status nginx
# Ver logs de acceso en tiempo real
tail -f /var/log/nginx/access.log
# Ver logs de errores
tail -f /var/log/nginx/error.log
# Verificar certificado SSL
certbot certificates
Con tu VPS y Nginx listos, el siguiente paso es asegurar tu servidor Linux con configuraciones básicas de seguridad.