¿Cómo se activa TLSV1.3 en Ninx? Vestacp / Centos o Ubuntu

En este tutorial aprenderás cómo activezi TLSv1.3 o NGINX. Qué significa TLSv 1.3, ¿Qué ayuda? y por qué necesitas en el servidor web como TLS se puede habilitar. Para servidores con sistema de gestión Vestacp (CentOS o Ubuntu) es un poco más difícil de activat TLS 1.3 que en un servidor cPanel, pero no es imposible.

¿Por qué TLS 1.3 es mejor que TLS 1.2?

TLS (Transport Layer Security) Es un protocolo criptográfico lo que asegura seguridad de conexión entre la computadora y una red de la cual forma parte. TLS se utiliza en aplicaciones como: correo electrónico, mensajero, llamadas de voz y video (VoIP), pero especialmente en HTTPS. Garantizar una comunicación segura entre el ordenador o smartphone del usuario y el servidor web de la página accedida.

TLS 1.3 ofrece un mayor velocidad inicio de sesión del cliente – servidor y un más seguridad eliminando algunos algoritmos. Las diferencias entre TLSV1.2 y TLSV1.3.

Acerca de HTTPS, SSL (Secure Sockets Layer) También dije en otros artículos:

Cómo habilitar TLS 1.3 en NGINX. Servidor con gestión VestaCP/CentOS

Antes de ver cómo habilitar TLSv1.3 en NGINX, hay algunos requisitos mínimos a considerar TLS 1.3.

  1. NGINX 1.13.x o posterior
  2. Un certificado TLS válido
  3. Nombre de dominio activo con DNS correctamente configurado – ser accesible en Internet
  4. Un certificado TLS/SSL válido. También puede ser Let’s Encrypt.

En VestaCP instalado hace tiempo, solo tenemos disponible el protocolo TLS 1.2. He visto en muchos tutoriales que es suficiente como en nginx.conf agregue la siguiente línea para habilitar TLS 1.3:

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;

FALSO. Si en un servidor Gestión de CentOS cu Vestacp, NGINX no fue compilado con la versión mínima OpenSSL 1.1.1.1, ssl_protocols TLSv1.2 TLSv1.3; en nginx.conf .. no ayuda en absoluto.

[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

Entonces, en el ejemplo anterior, Nginx 1.22.0 es compatible con TLS versión 1.3, pero no ayuda a nuestra biblioteca. OpenSSL 1.0.2k-fips.

Para habilitar TLSv1.3 en Nginx, primero debe instalar las bibliotecas secundarias y los paquetes de desarrollo. Development Tools. Ejecute en CentOS 7 las líneas de 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. Instale la última versión OpenSSL

En este momento la última versión es OpenSSL 1.1.1p, pero por lo que he visto, ya existía OpenSSL 3. Puede encontrar las fuentes en 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 

Muy importante para correr. make test antes de instalar la biblioteca. Si la prueba tiene errores, no la ejecute. make install hasta que se corrijan los errores.

En el siguiente paso hacemos una copia de seguridad del archivo binario actual. openssl y agregamos symlink al nuevo.

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

En /usr/local/openssl/bin ejecutar ldd para comprobar las dependencias de openssl. Posiblemente también podamos comprobar la versión de openssl. Dominio 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

Actualmente tenemos instalada la última versión. OpenSSL que perdura TLSv1.3. Podemos comprobar las versiones. TLS / SSL apoyado por librerías OpenSSL por orden:

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

Esto no significa que los sitios web alojados con la ayuda del administrador VestaCP tendrán inmediatamente TLS 1.3.

Aunque hemos instalado OpenSSL 1.1.1p, Nginx está compilado con la versión anterior. 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. Recompilar Nginx para el sistema. VestaCP

En este paso necesitamos recompilar para OpenSSL versión de Nginx ya instalada en el sistema CentOS / VestaCP. Como dije anteriormente, en mi caso se trata de nginx/1.22.0. Ya que estamos hablando de un servidor web que tiene VestaCP sistema de administración, antes de comenzar a compilar, es bueno hacer una copia de seguridad de los archivos de configuración de nginx.

Copia de seguridad de Nginx actual en el sistema VestaCP

Archive y guarde los directorios en algún lugar del servidor. “/etc/nginx” y “/usr/local/vesta/nginx“.

CORRER nginx -V y guarde los módulos existentes en un archivo.

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'
Cómo habilitar TLSv1.3 en NGINX
Semen de su página TLSv1.3 NGINX

Cómo recompilar Nginx para la actualización de OpenSSL/CentOS 7

Repito. si tienes Vestacp, descarga la versión de Nginx que ya tienes instalada. Puede encontrar todos los archivos con versiones de Nginx en 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

Recompilamos los módulos de 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

Ahora tenemos Nginx instalado y compilado con la última versión de OpenSSL capaz de soportar 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

*Si nginx ya estaba instalado en el servidor, deberá desinstalarlo. La compilación no funciona en la actualización de nginx.

Cómo habilitar TLSv1.3 para dominios en VestaCP

En el archivo /etc/nginx/nginx.conf agregamos las siguientes líneas:

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 nivel de dominio, cambié algo en las plantillas. VestaCP y habilitar HTTP/2. Entonces, cuando agrego un nuevo dominio (ejemplo.com) con Let's Encrypt habilitado, tengo el siguiente archivo de configuración para 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';

Antes de reiniciar nginx, es bueno probar primero su configuración.

[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

Espero que este tutorial te resulte útil y, si tienes algún problema, deja los detalles del problema en los comentarios.

Apasionado por la tecnología, escribo con placer en Stealthsetts.com a partir de 2006. Tengo una rica experiencia en sistemas operativos: macOS, Windows y Linux, pero también en lenguajes de programación y plataformas de blogs (WordPress) y para tiendas en línea (WooCommerce, Magento, Preshop).

Home Su fuente de tutoriales de TI, consejos útiles y noticias. ¿Cómo se activa TLSV1.3 en Ninx? Vestacp / Centos o Ubuntu
Deja un comentario