🔧 Installazione Nginx

sudo apt update

sudo apt install nginx-full -y


Verifica:

nginx -v

systemctl status nginx



🧩 Integrazione Nginx in Webmin

Se compare un errore, installa la dipendenza mancante:

sudo apt install libhtml-parser-perl -y

sudo systemctl restart webmin


✅ Dopo il riavvio, Nginx comparirà in “Servers”.

Nota: il modulo Webmin è solo di gestione, non influisce su Certbot.


✅ Procedura completa Certbot + Nginx (Webroot)

1️⃣ Installare Certbot

sudo apt update

sudo apt install certbot

sudo apt install python3-certbot-nginx


2️⃣ Creare la cartella per i challenge ACME

sudo mkdir -p /var/www/certbot

sudo chown www-data:www-data /var/www/certbot

sudo chmod 755 /var/www/certbot


3️⃣ Configurare Nginx per la sfida ACME

In ogni server block HTTP (porta 80) aggiungi:

location ^~ /.well-known/acme-challenge/ {

    root /var/www/certbot;

    allow all;

    auth_request off;

    access_log off;

    log_not_found off;

}


sudo nginx -t

sudo systemctl reload nginx



4️⃣ Richiedere il certificato (primo rilascio)

sudo certbot certonly \

  --webroot \

  -w /var/www/certbot \

  -d tuo-dominio.freeddns.org


📌 Più domini:

-d dominio1.example \

-d dominio2.example



5️⃣ Percorso certificati

I certificati verranno creati in:

/etc/letsencrypt/live/tuo-dominio.freeddns.org/


File principali:

6️⃣ Rinnovo automatico (già attivo)

Certbot installa automaticamente:

Test:

sudo certbot renew --dry-run


Rinnovo forzato:

sudo certbot renew --force-renewal



7️⃣ Reload automatico Nginx dopo rinnovo (consigliato)

Hook di deploy:

sudo nano /etc/letsencrypt/renewal-hooks/deploy/nginx-reload.sh


Contenuto:

#!/bin/bash

systemctl reload nginx


Permessi:

sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/nginx-reload.sh