编译安装NGINX并配置HTTPS和TLS1.3及HTTP/2
建议使用免费的Let’s Encrypt证书,可以到这里申请:https://www.sslforfree.com/
下载、解压、编译安装nginx:
wget http://nginx.org/download/nginx-1.16.0.tar.gz
tar zxf nginx-1.16.0.tar.gz
cd nginx-1.16.0
./configure --prefix=/usr/local/nginx --user=nobody --group=nobody --with-http_ssl_module --with-http_v2_module --with-pcre=/usr/local/pcre-8.43 --with-openssl=/usr/local/openssl-1.1.1b --with-zlib=/usr/local/zlib-1.2.11 && make && make install
注意,编译参数中软件的路径全是源码目录路径,不是安装目录的路径,而且OpenSSL必须为1.1.1版本。
编辑nginx配置文件:
vi /usr/local/nginx/conf/nginx.conf
server段部分配置如下:
server {
listen 443 ssl http2;
server_name www.test.com;
ssl_certificate ssl证书路径;
ssl_certificate_key ssl密钥路径;
ssl_session_cache shared:SSL:5m;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
}