In acest tutorial o să înveți cum activezi TLSv1.3 pe NGINX. Ce însemană TLSv 1.3و la ce ajută și de ce ai nevoie pe webserver ca TLS să poată fi activat. Pentru serverele cu sistem de management فيستاCP (CentOS sau Ubuntu) este puțin mai dificil de activat TLS 1.3 decât pe un server cu cPanel, însă nu este imposibil.
محتوى
De ce este mai bun TLS 1.3 decât TLS 1.2?
TLS (Transport Layer Security) إنه protocol criptografic care asigură securitatea conexiunii بين الكمبيوتر والشبكة التي هو جزء منها. TLS يتم استخدامه في تطبيقات مثل: بريد إلكترونيو رسولو مكالمات الصوت والفيديو ((VoIP)، ولكن بشكل خاص في HTTPS. ضمان الاتصال الآمن بين جهاز الكمبيوتر أو الهاتف الذكي الخاص بالمستخدم وخادم الويب الخاص بالصفحة التي يتم الوصول إليها.
TLS 1.3 يقدم أ سرعة أعلى تسجيل دخول العميل – الخادم و أ بالإضافة إلى الأمن عن طريق القضاء على بعض الخوارزميات. الاختلافات بين TLSv1.2 وTLSv1.3.
عن HTTPSو SSL ((Secure Sockets Layer) وقلت أيضًا في مقالات أخرى:
- كيف نقوم بتثبيت SSL (اتصال HTTPS) معتمد لموقع Hostat على خادم Nginx بدون cpanel أو Vertacp
- Recompilare openssl 1.1 & Ningin 1.25 لـ TLS 1.3 (Centos 7)
- كيفية نقل مدونة أو موقع وورد من HTTP إلى HTTPS (NGINX)
- حذف شهادات certbot المجالات القديمة (دعنا نش تشفير الشهادة)
Cum activezi TLS 1.3 pe NGINX. Server cu management VestaCP / CentOS
قبل النظر في كيفية تمكين TLSv1.3 على NGINX، هناك بعض المتطلبات الدنيا التي يجب مراعاتها TLS 1.3.
- NGINX 1.13.x أو الأحدث
- شهادة TLS صالحة
- اسم المجال النشط مع DNS الذي تم تكوينه بشكل صحيح – يمكن الوصول إليها على شبكة الإنترنت
- شهادة TLS/SSL صالحة. يمكن أن يكون كذلك Let’s Encrypt.
على VestaCP الذي تم تثبيته منذ فترة طويلة، لا يتوفر لدينا سوى البروتوكول TLS 1.2. لقد رأيت في العديد من البرامج التعليمية أنه يكفي كما في nginx.conf أضف السطر التالي لتمكين 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;
خطأ شنيع. لو على الخادم إدارة CentOS cu فيستاCPو لم يتم تجميع NGINX مع الحد الأدنى من الإصدار OpenSSL 1.1.1.1و ssl_protocols TLSv1.2 TLSv1.3; في nginx.conf .. لا يساعد على الإطلاق.
[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
لذلك في المثال أعلاه، Nginx 1.22.0 متوافق مع TLS الإصدار 1.3، لكن مكتبتنا لا تساعد OpenSSL 1.0.2k-fips.
لتمكين TLSv1.3 على Nginx، يجب عليك أولاً تثبيت المكتبات الفرعية وحزم التطوير. Development Tools. قم بتشغيل أسطر الأوامر في CentOS 7:
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. قم بتثبيت أحدث إصدار OpenSSL
في هذا الوقت هو الإصدار الأحدث OpenSSL 1.1.1p، ولكن بقدر ما رأيت، كان هناك بالفعل OpenSSL 3. يمكنك العثور على المصادر على 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
مهم جدا للتشغيل make test قبل تثبيت المكتبة. إذا كان الاختبار به أخطاء، فلا تقم بتشغيله make install حتى يتم تصحيح الأخطاء.
في الخطوة التالية نقوم بعمل نسخة احتياطية من الملف الثنائي الحالي openssl ونضيف symlink إلى الجديد.
mv /usr/bin/openssl /usr/bin/openssl-backup
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
في /usr/local/openssl/bin ينفذ ldd للتحقق من تبعيات opensl. ربما يمكننا أيضًا التحقق من إصدار opensl. يأمر 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
لدينا حاليًا أحدث إصدار مثبت OpenSSL الذي يتحمل TLSv1.3. يمكننا التحقق من الإصدارات TLS / SSL بدعم من المكتبات OpenSSL حسب الطلب:
[root@north bin]# openssl ciphers -v | awk '{print $2}' | sort | uniq
SSLv3
TLSv1
TLSv1.2
TLSv1.3
[root@north bin]#
وهذا لا يعني أن المواقع المستضافة تتم بمساعدة المدير VestaCP سيكون لديهم على الفور TLS 1.3.
على الرغم من أننا قمنا بتثبيت OpenSSL 1.1.1p، تم تجميع Nginx مع الإصدار القديم 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. أعد ترجمة Nginx للنظام VestaCP
في هذه الخطوة نحن بحاجة إلى إعادة ترجمة ل OpenSSL إصدار Nginx مثبت بالفعل على النظام CentOS / VestaCP. كما قلت أعلاه، في حالتي يتعلق الأمر nginx/1.22.0. بما أننا نتحدث عن خادم ويب يحتوي على VestaCP نظام الإدارة، قبل أن نبدأ في إعادة الترجمة، من الجيد عمل نسخة احتياطية من ملفات التكوين nginx.
النسخ الاحتياطي لـ Nginx الحالي على النظام VestaCP
أرشفة الدلائل واحتفظ بها في مكان ما على الخادم “/etc/nginx” و “/usr/local/vesta/nginx“.
يجري nginx -V وحفظ الوحدات الموجودة في ملف.
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'

Cum recompilezi Nginx pentru upgrage OpenSSL / CentOS 7
أكرر. إذا كان لديك فيستاCP، قم بتنزيل إصدار Nginx الذي قمت بتثبيته بالفعل. يمكنك العثور على جميع الأرشيفات التي تحتوي على إصدارات Nginx على 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
نقوم بإعادة ترجمة وحدات 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
لقد قمنا الآن بتثبيت Nginx وتجميعه بأحدث إصدار من OpenSSL قادرة على دعم 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
*إذا كان nginx مثبتًا بالفعل على الخادم، فستحتاج إلى إلغاء تثبيته. التجميع لا يعمل عند ترقية nginx.
Cum activezi TLSv1.3 pentru domenii pe VestaCP
في الملف /etc/nginx/nginx.conf نضيف الأسطر التالية:
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';
على مستوى المجال، قمت بتغيير شيء ما في القوالب VestaCP ولتمكين HTTP/2. لذا، عند إضافة نطاق جديد (example.com) مع تمكين Let's Encrypt، لدي ملف التكوين التالي لـ 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';
قبل إعادة تشغيل nginx، من الجيد اختبار تكوينه أولاً.
[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
أتمنى أن تجد هذا البرنامج التعليمي مفيدًا، وإذا واجهتك مشكلة ما، فاترك تفاصيل المشكلة في التعليقات.