Quantcast
Channel: CodeSection,代码区,网络安全 - CodeSec
Viewing all articles
Browse latest Browse all 12749

本站开启TLS 1.3

0
0

安装依赖

本站基于 Centos7+Oneinstack 搭建,如果你使用其它发行版,与包管理有关的命令请自行调整。

首先安装依赖库和编译要用到的工具:

yum -y install build-essential libpcre3 libpcre3-dev zlib1g-dev unzip git 获取必要组件

ngx_brotli

cd /root/oneinstack/src
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli
git submodule update --init
cd ../ OpenSSL

为了支持 TLS 1.3 final,需要使用 OpenSSL 1.1.1 正式版:

wget http://mirrors.linuxeye.com/oneinstack/src/openssl-1.1.1.tar.gz
tar xzf openssl-1.1.1.tar.gz Pcre wget http://mirrors.linuxeye.com/oneinstack/src/pcre-8.42.tar.gz
tar xzf pcre-8.42.tar.gz 编译并安装 Nginx

接着就可以获取 Nginx 源码,编译并安装:

wget -c http://nginx.org/download/nginx-1.15.6.tar.gz
tar zxf nginx-1.15.6.tar.gz
cd nginx-1.15.6
make clean
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-1.1.1 --with-openssl-opt='enable-tls1_3 enable-weak-ssl-ciphers' --with-pcre=../pcre-8.42 --with-pcre-jit --with-ld-opt=-ljemalloc --add-module=../ngx_brotli
make
mv /usr/local/nginx/sbin/nginx{,_`date +%m%d`} #备份现有nginx
cp objs/nginx /usr/local/nginx/sbin/ #更新nginx
nginx -t #检查nginx语法

enable-tls1_3 是让 OpenSSL 支持 TLS 1.3 的关键选项;而enable-weak-ssl-ciphers的作用是让 OpenSSL 继续支持 3DES 等不安全的 Cipher Suite,如果你打算继续支持 IE8,才需要加上这个选项。

WEB 站点配置

在 Nginx 的站点配置中,以下两个参数需要修改:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 增加 TLSv1.3
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;

包含 TLS13 是 TLS 1.3 新增的 Cipher Suite,加在最前面即可;如果你不打算继续支持 IE8,可以去掉包含3DES 的 Cipher Suite。

service nginx restart


Viewing all articles
Browse latest Browse all 12749

Latest Images

Trending Articles





Latest Images