このチュートリアルでは、その方法を説明します アクティベート TLSNGINXのv1.3、少し理解しましょう どういう意味ですか この TLS 1.3、 何が役立つか なぜ 必要です Webサーバー上で TLS 有効化する。 理由を理解しましょう サーバーと VestaCP (CentOS またはUbuntu)はもう少し難しいです 有効にするために TLS 1.3 cPanelサーバーよりも。 または、ホスティング管理ソフトウェアがないサーバー上。
なぜそれが良いのですか TLS 1.3より TLS 1.2?
TLS (Transport Layer Security)です 暗号化プロトコル これにより、 接続セキュリティ コンピュータとそれが属するネットワークの間。 TLS 次のようなアプリケーションで使用されます。 Eメール, メッセージング, 音声通話とビデオ通話 (VoIP)、特に HTTPS。 ユーザーのコンピューターまたはスマートフォンと、アクセスしたページのWebサーバーとの間の安全な通信を確保します。
TLSv1.3 提供 より高速 クライアント-サーバー接続と また、セキュリティ いくつかのアルゴリズムを排除することによって。 の違い TLSv1.2および TLSv1.3.
約 HTTPS, SSL (Secure Sockets Layer)他の記事でも述べています:
- 証明書のインストール方法 SSL (HTTPS 接続)cPanelまたはcPanelなしでNGINXサーバーでホストされているWebサイトの場合 VestaCP
- ブログやウェブサイトを移動する方法 WordPress HTTPから HTTPS (NGINX)
- 古いドメインを削除する Certbot certificates (証明書を暗号化しましょう)
アクティベートする方法 TLSNGINXのv1.3。 サーバーと VestaCP にインストールされています CentOS
アクティベートする方法を見る前に TLSNGINXのv1.3では、最小限のソフトウェア要件とライブラリが存在する必要があります。
- NGINX1.13.x以降
- 証明書 TLS 有効な
- 正しく構成されたDNSを持つアクティブなドメイン名-インターネット上でアクセス可能
- 証明書 TLS / SSL 有効。 Let'sEncryptの場合もあります。
に 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 VestaCP, NGINXはコンパイルされていません Openの最小バージョンでSSL 1.1.1.1、 ssl_protocols TLSv1.2 TLSv1.3;
in 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
したがって、上記の例では、Nginx1.22.0はと互換性があります TLSv1.3ですが、Openライブラリは役に立ちませんSSL 1.0.2k-fips。
有効にするために TLSNginxのv1.3では、最初に子ライブラリと開発パッケージをインストールする必要があります。 開発ツール。 実行します 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.最新のOpenバージョンをインストールしますSSL
現時点では、最新バージョンはOpenです。SSL 1.1.1pですが、私が気付いたところ、すでにOpenがありますSSL 3.ソースは次の場所にあります。 開いたSSL.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
エラーが修正されるまで。
次のステップでは、現在開いているバイナリファイルをバックアップしますssl 新しいシンボリックリンクにシンボリックリンクを追加します。
mv /usr/bin/openssl /usr/bin/openssl-backup
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
In /usr/local/openssl/bin
実行する ldd
開いている依存関係を確認するにはssl。 オープンバージョンも確認できますssl。 指示 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
現在、Openの最新バージョンがインストールされていますSSL そのサポート TLSv1.3。 バージョンを確認できます TLS / SSL オープンライブラリでサポートSSL 命令により:
[root@north bin]# openssl ciphers -v | awk '{print $2}' | sort | uniq
SSLv3
TLSv1
TLSv1.2
TLSv1.3
[root@north bin]#
これは、ウェブサイトがでホストされているという意味ではありません VestaCP 彼らはすぐに持っているでしょう TLS 1.3。 ない macarNginxはOpenの新しいバージョン用にまだコンパイルされていませんSSL.
OpenをインストールしていますがSSL 1.1.1p、Nginxは古いOpenバージョンでコンパイルされていますSSL 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
このステップでは、Open用に再コンパイルする必要がありますSSL すでにインストールされているNginxのバージョン pe CentOS / VestaCP。 上で述べたように、私の場合はnginx/1.22.0についてです。 を持っているウェブサーバーについてであること VestaCP のシステムとして admin再コンパイルを開始する前に、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'
Nginxをダウンロードしてコンパイルします
繰り返す。 あなたが持っている場合 VestaCP、すでにインストールされているバージョンの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がインストールされ、最新バージョンのOpenでコンパイルされました。SSL 耐えられる 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
アクティベートする方法 TLS上のドメインのv1.3 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を有効にする。 したがって、Let's Encryptを有効にして新しいドメイン(example.com)を追加すると、次の構成ファイルがあります。 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';
あなたの前に restartあなたは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
このチュートリアルがお役に立てば幸いです。うまくいかない場合は、問題の詳細をコメントに残してください。