nginx 1.25.1 支持了http2指令,http2指令独立之后,有些域名开启http2,有些域名可以不开启,listen指令的http2参数弃用
编译安装 openssl
参考:CentOS7 升级 OpenSSH 和 OpenSSL
编译安装 Nginx
wget http://nginx.org/download/nginx-1.22.0.tar.gz
tar xzf nginx-1.22.0.tar.gz
cd nginx-1.22.0
vim auto/lib/openssl/conf
$OPENSSL/.openssl # 去掉 .openssl
export PKG_CONFIG_PATH=/opt/openssl/lib/pkgconfig
export LD_LIBRARY_PATH=/opt/openssl/lib
./configure --prefix=/opt/nginx --with-stream --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_v2_module --with-openssl=/opt/openssl/
make
make install
配置 Nginx
vim nginx.conf
...
http {
...
server {
listen 443;
server_name aaa.xxx.com;
http2 on;
ssl_certificate
ssl_certificate_key
location / {
root html;
index index.html;
}
}
server {
listen 443;
server_name bbb.xxx.com;
http2 off;
ssl_certificate
ssl_certificate_key
location / {
root html;
index index.html;
}
}
...
}
...