Šajā apmācībā jūs uzzināsit, kā aktivizēt TLSv1.3 operētājsistēmā NGINX. Ko tas nozīmē TLSv 1.3, ko tas palīdz un kāpēc tev vajag tīmekļa serverī kā TLS var aktivizēt. Serveriem ar vadības sistēmu VestaCP (CentOS vai Ubuntu) ir nedaudz grūtāk lai aktivizētu TLS 1.3 nekā cPanel serverī, taču tas nav neiespējami.
Saturu
Kāpēc tas ir labāk TLS 1.3 nekā TLS 1.2?
TLS (Transport Layer Security) ir kriptogrāfijas protokols kas nodrošina savienojuma drošība starp datoru un tīklu, kura daļa tas ir. TLS to izmanto tādās lietojumprogrammās kā: e-pasts, Messaging, balss un videozvani (VoIP), bet jo īpaši plkst HTTPS. Drošas komunikācijas nodrošināšana starp lietotāja datoru vai viedtālruni un pieejamās lapas tīmekļa serveri.
TLS 1.3 piedāvā a lielāks ātrums savienojošo klientu – serveri un a Turklāt drošība likvidējot dažus algoritmus. Atšķirības starp TLSv1.2 un TLSv1.3.
Despre HTTPS, SSL (Secure Sockets Layer) Es arī citos rakstos teicu:
- Kā instalēt sertifikātu SSL (HTTPS Savienojums) vietnei, kas mitināta NGINX serverī bez cPanel vai VestaCP
- Pārkompilēt OpenSSL 1.1 un NGINX 1.25 TLS 1.3 (CentOS 7)
- Kā pārvietot emuāru vai vietni WordPress no HTTP uz HTTPS (Nginx)
- Dzēst vecos domēnus Certbot certificates (Šifrēsim sertifikātu)
Kā aktivizēt TLS 1.3 uz NGINX? Serveris ar VestaCP pārvaldību / CentOS
Pirms redzat, kā jūs aktivizējat TLSv1.3 operētājsistēmā NGINX, jums ir jāņem vērā dažas minimālās prasības TLS 1.3.
- NGINX 1.13.x vai jaunāka versija
- Sertifikāts TLS derīgs
- Aktīvs domēna nosaukums ar pareizi konfigurētu DNS – esi pieejams internetā
- Sertifikāts TLS / SSL derīgs. Tā arī var būt Let’s Encrypt.
Pe VestaCP instalēta jau sen, mums ir pieejams tikai protokols TLS 1.2. Daudzās pamācībās esmu redzējis, ka pietiek ar to kā ir nginx.conf
pievienosim šādu rindiņu apm TLS 1.3, kas jāaktivizē:
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;
Viltus. Ja serveris CentOS ar vadību VestaCP, NGINX nav apkopots ar minimālo versiju OpenSSL 1.1.1.1, ssl_protocols TLSv1.2 TLSv1.3;
iekš nginx.conf
.. tas nemaz nepalīdz.
[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
Tātad iepriekš minētajā piemērā Nginx 1.22.0 ir saderīga versija TLS 1.3, bet bibliotēka mums nepalīdz OpenSSL 1.0.2k-fips.
Lai aktivizētu TLSv1.3 operētājsistēmā Nginx, vispirms jāinstalē bērnu bibliotēkas un izstrādes pakotnes. Development Tools. Tas ieskrien CentOS 7 komandrindas:
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. Instalējiet jaunāko versiju OpenSSL
Šobrīd jaunākā versija ir OpenSSL 1.1.1p, bet cik esmu ievērojis ir jau un OpenSSL 3. Avotus varat atrast vietnē 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
Ļoti svarīgi skriet make test
pirms bibliotēkas instalēšanas. Ja testā ir kļūdas, nedarbiniet make install
līdz kļūdas tiek izlabotas.
Nākamajā darbībā mēs izveidojam pašreizējā binārā faila dublējumu openssl
un pievienojam symlink
uz jauno.
mv /usr/bin/openssl /usr/bin/openssl-backup
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
uz /usr/local/openssl/bin
izpildīt ldd
lai pārbaudītu openssl atkarības. Mēs, iespējams, varam pārbaudīt arī openssl versiju. Komanda 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
Pašlaik mums ir instalēta jaunākā versija OpenSSL kas iztur TLSv1.3. Mēs varam pārbaudīt versijas TLS / SSL atbalsta grāmatnīcas OpenSSL pēc pasūtījuma:
[root@north bin]# openssl ciphers -v | awk '{print $2}' | sort | uniq
SSLv3
TLSv1
TLSv1.2
TLSv1.3
[root@north bin]#
Tas nenozīmē, ka vietnes tiek mitinātas ar pārvaldnieka palīdzību VestaCP viņiem tas būs tūlīt TLS 1.3.
Lai gan esam uzstādījuši OpenSSL 1.1.1p, Nginx ir apkopots ar veco versiju 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. Pārkompilējiet Nginx sistēmai VestaCP
Šajā solī mums ir jāpārkompilē priekš OpenSSL Nginx versija jau ir instalēta sistēmā CentOS / VestaCP. Kā jau teicu iepriekš, manā gadījumā runa ir par nginx/1.22.0. Tā kā mēs runājam par tīmekļa serveri, kuram ir VestaCP administrēšanas sistēmu, pirms sākam pārkompilēšanu, ir labi izveidot nginx konfigurācijas failu dublējumu.
Dublējiet Nginx strāvu sistēmā VestaCP
Arhivējiet un saglabājiet direktorijus kaut kur serverī "/etc/nginx
" un "/usr/local/vesta/nginx
".
RUN nginx -V
un saglabājiet esošos moduļus failā.
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'
Kā pārkompilēt Nginx jaunināšanai OpenSSL / CentOS 7
ES atkārtoju. Ja Jums ir VestaCP, lejupielādējiet jau instalēto Nginx versiju. Jūs varat atrast visus arhīvus ar Nginx versijām 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
Mēs pārkompilējam nginx moduļus:
./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
Tagad mums ir instalēts Nginx un tas ir apkopots ar jaunāko versiju OpenSSL spēj izturēt 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
*ja nginx jau bija instalēts serverī, jums tas būs jāatinstalē. Kompilēšana nedarbojas ar nginx jaunināšanu.
Kā aktivizēt TLSv1.3 domēniem uz VestaCP?
Failā /etc/nginx/nginx.conf
pievienojam šādas rindas:
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';
Domēna līmenī es kaut ko mainīju veidnēs VestaCP un lai iespējotu HTTP/2. Tātad, pievienojot jaunu domēnu (example.com) ar iespējotu šifrēšanu, man ir šāds konfigurācijas fails 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';
Pirms nginx restartēšanas ir lietderīgi vispirms pārbaudīt tā konfigurāciju.
[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
Es ceru, ka šī apmācība jums noderēs, un, ja jums kaut kas ir iestrēdzis, komentāros atstājiet informāciju par problēmu.