本站開啟TLS 1.3
安裝依賴
本站基於 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 正式版:
wgethttp://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_protocolsTLSv1 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