Practica Unidad 10: Nginx y SSL
Practica Unidad 10: Nginx y SSL
Objetivo
Instalar Nginx, configurar un sitio (server block) y entregar evidencias. (Certbot es opcional si no tienes dominio publico).
Parte 1: Instalacion y validacion
BASH
- 1
- apt update actualiza el indice.
- 2
- apt install nginx instala Nginx.
- 3
- systemctl status valida servicio.
- 4
- curl -I valida respuesta.
Parte 2: Server block
BASH
1$ sudo tee /etc/nginx/sites-available/app.conf >/dev/null <<'EOF'
server {
listen 80;
server_name app.local;
location / { return 200 "app ok\n"; }
}
EOF
2$ sudo ln -sf /etc/nginx/sites-available/app.conf /etc/nginx/sites-enabled/app.conf
3$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
4$ sudo systemctl reload nginx
5$ curl -i -H 'Host: app.local' http://127.0.0.1/
HTTP/1.1 200 OK
Server: nginx
app ok- 1
- tee + heredoc crea el sitio.
- 2
- ln -sf habilita el sitio.
- 3
- nginx -t valida configuracion.
- 4
- systemctl reload aplica.
- 5
- curl -H Host prueba el server block.
Parte 3 (opcional): Certbot
BASH
- 1
- apt install certbot instala Certbot.
- 2
- certbot –nginx emite certificado y configura TLS.
- 3
- certbot renew –dry-run valida renovacion.