Apache HTTP Server: differenze tra le versioni

 
(12 versioni intermedie di uno stesso utente non sono mostrate)
Riga 185: Riga 185:


=== Certbot ===
=== Certbot ===
<br/>
{{Box|IMPORTANTE|EFF consiglia ora di installare <code>certbot</code> usando <code>snapd</code> (vedere la [https://certbot.eff.org/ pagina dedicata] di EFF).}}


==== Premessa ====
==== Premessa ====


Nel seguito di questa sezione si faranno le seguenti ipotesi:
Nel seguito di questa sezione si faranno le seguenti ipotesi:
* l'utente usa le porte standard, ovvero '''80''' e '''443'''. In caso contrario molti degli automatismi dello strumento andrebbero persi e la procedura standard non sarebbe più applicabile;
* l'utente ha le porte standard, ovvero '''80''' e '''443''', aperte anche in ingresso. In caso contrario molti degli automatismi dello strumento andrebbero persi e la procedura standard non sarebbe più applicabile. Da notare che i propri virtualhost possono usare qualsiasi porta, ovvero non sono obbligati ad usare le porte standard, è semplicemente <code>certbot</code> che richiede che dette porte siano aperte per funzionare correttamente;
* l'utente ha già configurato il proprio eventuale firewall di rete in modo da reindirizzare correttamente le succitate porte.
* l'utente ha già configurato il proprio eventuale firewall di rete in modo da reindirizzare correttamente le succitate porte.
* l'utente non è interessato ad ottenere ''wild certificates'', cioè un certificato che copra tutti i possibili sottodomini (tipo ''*.mio_dominio.abc'').
* l'utente non è interessato ad ottenere ''wild certificates'', cioè un certificato che copra tutti i possibili sottodomini (tipo ''*.mio_dominio.abc'').
Riga 205: Riga 207:
Nel caso di singolo dominio e riprendendo l'esempio fatto precedentemente il comando diviene
Nel caso di singolo dominio e riprendendo l'esempio fatto precedentemente il comando diviene
<pre># certbot -d ind1.mio_dominio.abc</pre>
<pre># certbot -d ind1.mio_dominio.abc</pre>
che in caso di operazione andata a buon fine restituirà qualcosa di simile a
Lo strumento proporrà innanzitutto tre domande
<pre>
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:
</pre>
Dopo di che se la configurazione è andata a buon fine restituirà qualcosa di simile a
<pre>
<pre>
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Riga 230: Riga 255:
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):  
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):  
</pre>
</pre>
e rispondendo "2":
Se si risponde uno sarà onere dell'utente modificare opportunamente i file conf del proprio sito web, viceversa rispondendo "2" sarà visualizzato qualcosa di simile a quanto segue:
<pre>
<pre>
Enabled Apache rewrite module                                                                                                     
Enabled Apache rewrite module                                                                                                     
Riga 290: Riga 315:
</pre>
</pre>
In sintesi quello che succede è che il file di conf originale, cioè <code>mio_sito.conf</code>, viene modificato in modo da reindirizzare tutte le richieste dirette al virtualhost configurato sulla porta 80 a quello sulla porta 443, ovvero ogni richiesta http viene automaticamente convertita in una https.<br>
In sintesi quello che succede è che il file di conf originale, cioè <code>mio_sito.conf</code>, viene modificato in modo da reindirizzare tutte le richieste dirette al virtualhost configurato sulla porta 80 a quello sulla porta 443, ovvero ogni richiesta http viene automaticamente convertita in una https.<br>
Se non si avesse alcun interesse a mantenere il virtualhost sulla porta 80 si può disabilitare/eliminare il file <code>mio_sito.conf</code> senza problemi, tuttavia è bene sapere che tutte le richieste '''http''' non verranno più inoltrate automaticamente su '''https''', quindi l'utente si vedrà restituire dal webserver un errore ''403 Forbidden'' (è quindi fondamentale che chi già fruiva in precedenza del sito sia informato del cambio).
Se non si avesse alcun interesse a mantenere il virtualhost sulla porta 80 si può disabilitare/eliminare il file <code>mio_sito.conf</code> senza problemi, tuttavia è bene sapere che tutte le richieste http non verranno più inoltrate automaticamente su https, quindi l'utente si vedrà restituire dal webserver un errore ''403 Forbidden'' (è quindi fondamentale che chi già fruiva in precedenza del sito sia informato del cambio).
 
==== Rinnovo dei certificati ====
 
Certbot permette di rinnovare in automatico tutti i propri certificati con il comando <code>certbot renew</code>. Per testare subito che il predetto comando funzioni è possibile usare l'opzione <code>--dry-run</code>, ovvero:
<pre># certbot renew --dry-run</pre>
che in caso di successo dovrebbe restituire qualcosa di simile a:
<pre>
Saving debug log to /var/log/letsencrypt/letsencrypt.log
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/ind1.mio_dominio.abc.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for ind1.mio_dominio.abc
Waiting for verification...
Cleaning up challenges
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/ind1.mio_dominio.abc/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates below have not been saved.)
 
Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/ind1.mio_dominio.abc/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
  configuration directory at /etc/letsencrypt. You should make a
  secure backup of this folder now. This configuration directory will
  also contain certificates and private keys obtained by Certbot so
  making regular backups of this folder is ideal.
</pre>
A questo punto è possibile automatizzare il processo di rinnovo inserendo in [[Utilizzo del servizio di scheduling Cron | crontab]] il comando <code>certbot renew -q</code>, visto che i certificati '''NON''' saranno rinnovati a meno che non siano prossimi alla scadenza (l'opzione <code>-q</code> permette di sopprimere l'output del comando, fatta eccezione per eventuali errori).<br>
Per esempio volendo ripetere la verifica ogni 10 del mese alla 1:30 la riga da inserire in [[Utilizzo del servizio di scheduling Cron | crontab]] sarebbe:
<pre>30 1 10 * * /usr/bin/certbot renew -q</pre>


==== Errori ====
==== Errori ====
2 894

contributi