Come attivare TLSv1.3 su NGINX. VestaCP / CentOS o Ubuntu

In questo tutorial imparerai come permettere TLSv1.3 su NGINX. Cosa significa TLSv 1.3, cosa aiuta e perché hai bisogno sul server web come TLS può essere attivato. Per server con sistema di gestione VestaCP (CentOS o Ubuntu) è un po' più difficile attivare TLS 1.3 che su un server cPanel, ma non è impossibile.

Perché è meglio TLS 1.3 di TLS 1.2?

TLS (Transport Layer Security) è un protocollo crittografico che assicura sicurezza della connessione tra il computer e una rete di cui fa parte. TLS è utilizzato in applicazioni come: email, messaggistica, chiamate vocali e video (VoIP), ma soprattutto a HTTPS. Garantire una comunicazione sicura tra il computer o lo smartphone dell'utente e il server Web della pagina a cui si accede.

TLS 1.3 offre un maggiore velocità di connessione client – ​​server e a Inoltre la sicurezza eliminando alcuni algoritmi. Le differenze tra TLSv1.2 e TLSv1.3.

Circa HTTPS, SSL (Secure Sockets Layer) Ho anche detto in altri articoli:

Come attivare TLS 1.3 su NGINX. Server con gestione VestaCP / CentOS

Prima di vedere come si attiva TLSv1.3 su NGINX, è necessario considerare alcuni requisiti minimi per TLS 1.3.

  1. NGINX 1.13.xo successivo
  2. Un certificato TLS un valido
  3. Nome di dominio attivo con DNS configurato correttamente: essere accessibile su Internet
  4. Un certificato TLS / SSL valido. Può anche essere Let’s Encrypt.

Pe VestaCP installato molto tempo fa, abbiamo solo il protocollo disponibile TLS 1.2. Ho visto in molti tutorial che è abbastanza come in nginx.conf aggiungiamo la seguente riga per ca TLS 1.3 da attivare:

server {

  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  server_name example.com;
  root /var/www/example.com/public;

  ssl_certificate /path/to/your/certificate.crt;
  ssl_certificate_key /path/to/your/private.key;

  ssl_protocols TLSv1.2 TLSv1.3;

Impostore. Se server CentOS con la gestione VestaCP, NGINX non è stato compilato con la versione minima OpenSSL 1.1.1.1, ssl_protocols TLSv1.2 TLSv1.3; in nginx.conf .. non aiuta affatto.

[root@north ~]# nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled

Quindi nell'esempio precedente Nginx 1.22.0 è la versione compatibile TLS 1.3, ma la libreria non ci aiuta OpenSSL 1.0.2k-fips.

Attivare TLSv1.3 su Nginx, devi prima installare le librerie figlie e i pacchetti di sviluppo. Development Tools. Corre dentro CentOS 7 righe di comando:

yum install gcc gcc-c++ pcre-devel zlib-devel make unzip gd-devel perl-ExtUtils-Embed libxslt-devel openssl-devel perl-Test-Simple
yum groupinstall 'Development Tools'

1. Installa l'ultima versione OpenSSL

In questo momento l'ultima versione è OpenSSL 1.1.1p, ma per quanto ho notato c'è già e OpenSSL 3. Puoi trovare le fonti su OpenSSL.org.

cd /usr/src
wget https://www.openssl.org/source/openssl-1.1.1p.tar.gz
tar xvf openssl-1.1.1p.tar.gz 
mv openssl-1.1.1p openssl
cd openssl
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl --libdir=/lib64 shared zlib-dynamic
make -j4
make test 
make install 

Molto importante per correre make test prima di installare la libreria. Se il test contiene errori, non eseguire make install finché gli errori non vengono corretti.

Nel passaggio successivo eseguiamo un backup del file binario corrente openssl e aggiungiamo symlink a quello nuovo.

mv /usr/bin/openssl /usr/bin/openssl-backup
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

în /usr/local/openssl/bin eseguire ldd per controllare le dipendenze openssl. Possiamo eventualmente anche controllare la versione di openssl. Comando openssl version.

[root@north bin]# ldd openssl
	linux-vdso.so.1 =>  (0x00007ffd20bd7000)
	libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007fab09b62000)
	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007fab09675000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fab09471000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fab09255000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fab08e87000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fab09df5000)
[root@north bin]# openssl version
OpenSSL 1.1.1p  21 Jun 2022

Attualmente abbiamo l'ultima versione installata OpenSSL che resiste TLSv1.3. Possiamo controllare le versioni TLS / SSL supportato dalle librerie OpenSSL per ordine:

[root@north bin]# openssl ciphers -v | awk '{print $2}' | sort | uniq
SSLv3
TLSv1
TLSv1.2
TLSv1.3
[root@north bin]# 

Ciò non significa che i siti Web siano ospitati con l'aiuto del gestore VestaCP avranno subito TLS 1.3.

Anche se abbiamo installato OpenSSL 1.1.1p, Nginx è compilato con la vecchia versione OpenSSL 1.0.2k-fips.

[root@north bin]# nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
[root@north bin]# openssl version
OpenSSL 1.1.1p  21 Jun 2022
[root@north bin]# 

2. Ricompilare Nginx per il sistema VestaCP

In questo passaggio abbiamo bisogno di ricompilare for OpenSSL versione di Nginx già installata sul sistema CentOS / VestaCP. Come ho detto sopra, nel mio caso si tratta di nginx/1.22.0. Dal momento che stiamo parlando di un server web che ha VestaCP sistema di amministrazione, prima di iniziare la ricompilazione è bene fare un backup dei file di configurazione di nginx.

Backup Nginx corrente sul sistema VestaCP

Archivia e conserva da qualche parte sul server le directory "/etc/nginx"E"/usr/local/vesta/nginx".

CORRERE nginx -V e salvare i moduli esistenti in un file.

configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
Come si attiva? TLSv1.3 su NGINX
Come attivarlo TLSv1.3 su NGINX

Come ricompilare Nginx per l'aggiornamento OpenSSL / CentOS 7

Io ripeto. Se hai VestaCP, scarica la versione di Nginx che hai già installato. Puoi trovare tutti gli archivi con le versioni di Nginx attive nginx.org.

cd /usr/src
wget https://nginx.org/download/nginx-1.22.0.tar.gz 
tar xvf nginx-1.22.0.tar.gz
cd nginx-1.22.0

Ricompiliamo i moduli nginx:

./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \ 
--modules-path=/usr/lib64/nginx/modules \ 
--conf-path=/etc/nginx/nginx.conf \ 
--error-log-path=/var/log/nginx/error.log  \
--http-log-path=/var/log/nginx/access.log  \
--pid-path=/var/run/nginx.pid  \
--lock-path=/var/run/nginx.lock  \
--http-client-body-temp-path=/var/cache/nginx/client_temp  \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp  \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp  \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp  \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp  \
--user=nginx  \
--group=nginx  \
--with-compat  \
--with-file-aio  \
--with-threads  \
--with-http_addition_module  \
--with-http_auth_request_module  \
--with-http_dav_module  \
--with-http_flv_module  \
--with-http_gunzip_module  \
--with-http_gzip_static_module  \
--with-http_mp4_module  \
--with-http_random_index_module  \
--with-http_realip_module  \
--with-http_secure_link_module  \
--with-http_slice_module  \
--with-http_ssl_module  \
--with-http_stub_status_module  \
--with-http_sub_module  \
--with-http_v2_module  \
--with-mail  \
--with-mail_ssl_module  \
--with-stream  \
--with-stream_realip_module  \
--with-stream_ssl_module  \
--with-stream_ssl_preread_module  \
--with-openssl=/usr/src/openssl  \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong  \
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC'  \
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
make -j4
make install

Ora abbiamo Nginx installato e compilato con l'ultima versione di OpenSSL in grado di resistere TLSv1.3.

[root@north bin]# nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.1.1p  21 Jun 2022
TLS SNI support enabled

*se nginx era già installato sul server, sarà necessario disinstallarlo. La compilazione non funziona sull'aggiornamento di nginx.

Come attivare TLSv1.3 per i domini su VestaCP

Nel fascicolo /etc/nginx/nginx.conf aggiungiamo le seguenti righe:

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';

A livello di dominio, ho cambiato qualcosa nei template VestaCP e per abilitare HTTP/2. Quindi, quando aggiungo un nuovo dominio (example.com) con Let's Encrypt abilitato, ho il seguente file di configurazione per il SSL:

cat /home/vestacpuser/conf/web/example.com.nginx.ssl.conf 

server {
    listen      IP.IP.IP.IP:443 ssl http2;
    server_name example.com www.example.com;
    root        /home/vestacpuser/web/example.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/example.com.log combined;
    access_log  /var/log/nginx/domains/example.com.bytes bytes;
    error_log   /var/log/nginx/domains/example.com.error.log error;

    ssl_certificate      /home/vestacpuser/conf/web/ssl.example.com.pem;
    ssl_certificate_key  /home/vestacpuser/conf/web/ssl.example.com.key;

....

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';

Prima di riavviare nginx, è bene testarne prima la configurazione.

[root@north web]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@north web]# systemctl restart nginx

Spero che questo tutorial ti sia stato utile e se sei bloccato con qualcosa, lascia i dettagli del problema nei commenti.

Appassionato di tecnologia, scrivo con piacere su StealthSettings.com dal 2006. Ho un'ampia esperienza nei sistemi operativi: macOS, Windows e Linux, nonché nei linguaggi di programmazione e nelle piattaforme di blogging (WordPress) e per i negozi online (WooCommerce, Magento, PrestaShop).

Come » Linux » Come attivare TLSv1.3 su NGINX. VestaCP / CentOS o Ubuntu
Lascia un tuo commento